Annotate

mod_file_management/mod_file_management.lua @ 6302:06fbbd45ba75

mod_cloud_notify: Readme: fix links and labels that were removed in the last commit diff --git a/mod_cloud_notify/README.md b/mod_cloud_notify/README.md --- a/mod_cloud_notify/README.md +++ b/mod_cloud_notify/README.md @@ -1,3 +1,9 @@ +---- +-labels: +-- 'Stage-Beta' +-summary: 'XEP-0357: Cloud push notifications' +---- + # Introduction This module enables support for sending "push notifications" to clients @@ -32,15 +38,15 @@ notification to your device. When your d it will display it or wake up the app so it can connect to XMPP and receive any pending messages. -This protocol is described for developers in \[XEP-0357: Push -Notifications\]. +This protocol is described for developers in [XEP-0357: Push +Notifications]. -For this module to work reliably, you must have \[mod_smacks\], -\[mod_mam\] and \[mod_carbons\] also enabled on your server. +For this module to work reliably, you must have [mod_smacks], +[mod_mam] and [mod_carbons] also enabled on your server. Some clients, notably Siskin and Snikket iOS need some additional extensions that are not currently defined in a standard XEP. To support -these clients, see \[mod_cloud_notify_extensions\]. +these clients, see [mod_cloud_notify_extensions]. # Configuration @@ -58,18 +64,18 @@ these clients, see \[mod_cloud_notify_ex # Internal design notes App servers are notified about offline messages, messages stored by -\[mod_mam\] or messages waiting in the smacks queue. The business rules +[mod_mam] or messages waiting in the smacks queue. The business rules outlined [here](//mail.jabber.org/pipermail/standards/2016-February/030925.html) are all honored[^2]. -To cooperate with \[mod_smacks\] this module consumes some events: +To cooperate with [mod_smacks] this module consumes some events: `smacks-ack-delayed`, `smacks-hibernation-start` and `smacks-hibernation-end`. These events allow this module to send out notifications for messages received while the session is hibernated by -\[mod_smacks\] or even when smacks acknowledgements for messages are +[mod_smacks] or even when smacks acknowledgements for messages are delayed by a certain amount of seconds configurable with the -\[mod_smacks\] setting `smacks_max_ack_delay`. +[mod_smacks] setting `smacks_max_ack_delay`. The `smacks_max_ack_delay` setting allows to send out notifications to clients which aren't already in smacks hibernation state (because the
author Menel <menel@snikket.de>
date Fri, 13 Jun 2025 10:44:37 +0200
parent 3663:d43623bdf91b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3663
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 -- mod_file_management
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 --
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 -- Copyright (C) 2019 Emmanuel Gil Peyrot
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 --
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 -- This file is MIT/X11 licensed.
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 --
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 module:depends("http_upload");
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 local dataform_new = require "util.dataforms".new;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 local adhoc_new = module:require "adhoc".new;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 local adhoc_simple_form = require "util.adhoc".new_simple_form;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 local adhoc_initial_data_form = require "util.adhoc".new_initial_data_form;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 local url = require "socket.url";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 local lfs = require "lfs";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 local datamanager = require "util.datamanager";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 local jid_prepped_split = require "util.jid".prepped_split;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 local join_path = require "util.paths".join;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 local t_concat = table.concat;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 local t_insert = table.insert;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 local storage_path = module:get_option_string("http_upload_path", join_path(prosody.paths.data, "http_upload"));
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 local function get_url(dir, filename)
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 local slot_url = url.parse(module:http_url("upload"));
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 slot_url.path = url.parse_path(slot_url.path or "/");
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 t_insert(slot_url.path, dir);
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 t_insert(slot_url.path, filename);
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 slot_url.path.is_directory = false;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 slot_url.path = url.build_path(slot_url.path);
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 return url.build(slot_url);
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 end
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 local list_form = dataform_new {
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 title = "List files for user";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 instructions = "Select the JID of a user to list the files they have uploaded.";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 {
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 type = "hidden";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 name = "FORM_TYPE";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 value = "http://prosody.im/protocol/file_management#list";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 };
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 {
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 type = "jid-single";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 name = "accountjid";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 required = true;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 label = "JID";
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 };
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 };
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 module:provides("adhoc", adhoc_new("File Management", "http://prosody.im/protocol/file_management#list", adhoc_simple_form(list_form, function (data, errors)
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 if errors then
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 local errmsg = {};
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 for name, text in pairs(errors) do
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 errmsg[#errmsg + 1] = name .. ": " .. text;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54 end
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 return { status = "completed", error = { message = t_concat(errmsg, "\n") } };
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 end
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58 local jid = data.accountjid;
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 local user, host = jid_prepped_split(jid);
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61 local uploads, err = datamanager.list_load(user, host, "http_upload");
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 if err then
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 return { status = "completed", error = "File upload data not found for user "..jid.."." };
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 end
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66 local result = {};
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
67 for i, upload in ipairs(uploads) do
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 module:log("debug", "http_upload_management#list %d %q", i, upload);
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
69 if upload.dir ~= nil then
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 t_insert(result, get_url(upload.dir, upload.filename));
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
71 else
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
72 -- upload.filename was pointing to a path on the file system…
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73 -- TODO: Try to guess the URL from that.
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74 end
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 end
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77 return { status = "completed", info = t_concat(result, "\n") };
d43623bdf91b mod_upload_file_management: Add this new module, for now only listing files uploaded by a user as an admin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 end), "admin"));