comparison mod_http_admin_api/mod_http_admin_api.lua @ 5897:896e7c7bf87f

Merge
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Tue, 30 Apr 2024 15:07:06 -0500
parents 095030677ae6
children 4b52d579bc70
comparison
equal deleted inserted replaced
5896:5b95e06d75d5 5897:896e7c7bf87f
78 end 78 end
79 79
80 local function token_info_to_invite_info(token_info) 80 local function token_info_to_invite_info(token_info)
81 local additional_data = token_info.additional_data; 81 local additional_data = token_info.additional_data;
82 local groups = additional_data and additional_data.groups or nil; 82 local groups = additional_data and additional_data.groups or nil;
83 local roles = additional_data and additional_data.roles or nil;
83 local source = additional_data and additional_data.source or nil; 84 local source = additional_data and additional_data.source or nil;
85 local note = additional_data and additional_data.note or nil;
84 local reset = not not (additional_data and additional_data.allow_reset or nil); 86 local reset = not not (additional_data and additional_data.allow_reset or nil);
85 return { 87 return {
86 id = token_info.token; 88 id = token_info.token;
87 type = token_info.type; 89 type = token_info.type;
88 reusable = not not token_info.reusable; 90 reusable = not not token_info.reusable;
91 uri = token_info.uri; 93 uri = token_info.uri;
92 landing_page = token_info.landing_page; 94 landing_page = token_info.landing_page;
93 created_at = token_info.created_at; 95 created_at = token_info.created_at;
94 expires = token_info.expires; 96 expires = token_info.expires;
95 groups = groups; 97 groups = groups;
98 roles = roles;
96 source = source; 99 source = source;
97 reset = reset; 100 reset = reset;
101 note = note;
98 }; 102 };
99 end 103 end
100 104
101 function list_invites(event) 105 function list_invites(event)
102 local invites_list = {}; 106 local invites_list = {};
151 if not options.groups then 155 if not options.groups then
152 return 400; 156 return 400;
153 end 157 end
154 invite = invites.create_group(options.groups, { 158 invite = invites.create_group(options.groups, {
155 source = source; 159 source = source;
160 roles = options.roles;
161 note = options.note;
156 }, options.ttl); 162 }, options.ttl);
157 elseif invite_type == "account" then 163 elseif invite_type == "account" then
158 invite = invites.create_account(options.username, { 164 invite = invites.create_account(options.username, {
159 source = source; 165 source = source;
160 groups = options.groups; 166 groups = options.groups;
167 roles = options.roles;
168 note = options.note;
161 }, options.ttl); 169 }, options.ttl);
162 else 170 else
163 return 400; 171 return 400;
164 end 172 end
165 if not invite then 173 if not invite then
761 result.memory = maybe_export_plain_gauge(families.process_resident_memory_bytes); 769 result.memory = maybe_export_plain_gauge(families.process_resident_memory_bytes);
762 result.cpu = maybe_export_plain_counter(families.process_cpu_seconds); 770 result.cpu = maybe_export_plain_counter(families.process_cpu_seconds);
763 result.c2s = maybe_export_summed_gauge(families["prosody_mod_c2s/connections"]) 771 result.c2s = maybe_export_summed_gauge(families["prosody_mod_c2s/connections"])
764 result.uploads = maybe_export_summed_gauge(families["prosody_mod_http_file_share/total_storage_bytes"]); 772 result.uploads = maybe_export_summed_gauge(families["prosody_mod_http_file_share/total_storage_bytes"]);
765 result.users = { 773 result.users = {
766 active_1d = maybe_export_plain_gauge(families["prosody_mod_measure_active_users/active_users_1d"]); 774 active_1d = maybe_export_summed_gauge(families["prosody_mod_measure_active_users/active_users_1d"]);
767 active_7d = maybe_export_plain_gauge(families["prosody_mod_measure_active_users/active_users_7d"]); 775 active_7d = maybe_export_summed_gauge(families["prosody_mod_measure_active_users/active_users_7d"]);
768 active_30d = maybe_export_plain_gauge(families["prosody_mod_measure_active_users/active_users_30d"]); 776 active_30d = maybe_export_summed_gauge(families["prosody_mod_measure_active_users/active_users_30d"]);
769 }; 777 };
770 return json.encode(result); 778 return json.encode(result);
771 end 779 end
772 780
773 local function post_server_announcement(event) 781 local function post_server_announcement(event)
793 local host = module.host 801 local host = module.host
794 message.attr.from = host 802 message.attr.from = host
795 if body.recipients == "online" then 803 if body.recipients == "online" then
796 announce.send_to_online(message, host); 804 announce.send_to_online(message, host);
797 elseif body.recipients == "all" then 805 elseif body.recipients == "all" then
798 for username in usermanager.users(host) do 806 if announce.send_to_all then
799 message.attr.to = username .. "@" .. host 807 announce.send_to_all(message, host);
800 module:send(st.clone(message)) 808 else -- COMPAT w/ 0.12 and trunk before e22609460975
809 for username in usermanager.users(host) do
810 message.attr.to = username .. "@" .. host
811 module:send(st.clone(message))
812 end
801 end 813 end
802 else 814 else
803 for _, addr in ipairs(body.recipients) do 815 for _, addr in ipairs(body.recipients) do
804 message.attr.to = addr 816 message.attr.to = addr
805 module:send(message) 817 module:send(message)