Mercurial > prosody-modules
comparison mod_http_upload/mod_http_upload.lua @ 2066:cb74e4ab13f0
mod_http_upload: Advertise maximum file size in disco#info (Per XEP-0363 v0.2)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 08 Mar 2016 19:36:27 +0100 |
parents | 624e3fed6f92 |
children | e47046abf568 |
comparison
equal
deleted
inserted
replaced
2065:624e3fed6f92 | 2066:cb74e4ab13f0 |
---|---|
10 -- imports | 10 -- imports |
11 local st = require"util.stanza"; | 11 local st = require"util.stanza"; |
12 local lfs = require"lfs"; | 12 local lfs = require"lfs"; |
13 local uuid = require"util.uuid".generate; | 13 local uuid = require"util.uuid".generate; |
14 local urlencode = require"util.http".urlencode; | 14 local urlencode = require"util.http".urlencode; |
15 local dataform = require "util.dataforms".new; | |
15 local t_concat = table.concat; | 16 local t_concat = table.concat; |
16 local t_insert = table.insert; | 17 local t_insert = table.insert; |
17 local s_upper = string.upper; | 18 local s_upper = string.upper; |
18 | 19 |
19 local function join_path(a, b) | 20 local function join_path(a, b) |
29 | 30 |
30 -- namespace | 31 -- namespace |
31 local xmlns_http_upload = "urn:xmpp:http:upload"; | 32 local xmlns_http_upload = "urn:xmpp:http:upload"; |
32 | 33 |
33 module:add_feature(xmlns_http_upload); | 34 module:add_feature(xmlns_http_upload); |
35 | |
36 module:add_extension(dataform { | |
37 { name = "FORM_TYPE", type = "hidden", value = xmlns_http_upload }, | |
38 { name = "max-file-size", type = "text-single" }, | |
39 }:form({ ["max-file-size"] = tostring(file_size_limit) }, "result")); | |
34 | 40 |
35 -- state | 41 -- state |
36 local pending_slots = module:shared("upload_slots"); | 42 local pending_slots = module:shared("upload_slots"); |
37 | 43 |
38 local storage_path = module:get_option_string(module.name .. "_path", join_path(prosody.paths.data, module.name)); | 44 local storage_path = module:get_option_string(module.name .. "_path", join_path(prosody.paths.data, module.name)); |