aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-08-30 00:11:58 +0200
committerKim Alvefur <zash@zash.se>2021-08-30 00:11:58 +0200
commit8d25086ac19b2f01005d03221abb538e009fa82d (patch)
tree1259006ac13d1da79684f87dbf031814cd005d7a /plugins
parente8b53c328e6349934babe04ac8ff342378790e09 (diff)
downloadprosody-8d25086ac19b2f01005d03221abb538e009fa82d.tar.gz
prosody-8d25086ac19b2f01005d03221abb538e009fa82d.zip
mod_external_services: Factor out public function returning current services
This way you get the _prepared_ services and don't have to do that mapping yourself.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_external_services.lua19
1 files changed, 11 insertions, 8 deletions
diff --git a/plugins/mod_external_services.lua b/plugins/mod_external_services.lua
index 871c275f..3a92dc2d 100644
--- a/plugins/mod_external_services.lua
+++ b/plugins/mod_external_services.lua
@@ -122,6 +122,15 @@ local services_mt = {
end;
}
+function get_services()
+ local extras = module:get_host_items("external_service");
+ local services = ( configured_services + extras ) / prepare;
+
+ setmetatable(services, services_mt);
+
+ return services;
+end
+
local function handle_services(event)
local origin, stanza = event.origin, event.stanza;
local action = stanza.tags[1];
@@ -134,8 +143,7 @@ local function handle_services(event)
end
local reply = st.reply(stanza):tag("services", { xmlns = action.attr.xmlns });
- local extras = module:get_host_items("external_service");
- local services = ( configured_services + extras ) / prepare;
+ local services = get_services();
local requested_type = action.attr.type;
if requested_type then
@@ -144,8 +152,6 @@ local function handle_services(event)
end);
end
- setmetatable(services, services_mt);
-
module:fire_event("external_service/services", {
origin = origin;
stanza = stanza;
@@ -181,8 +187,7 @@ local function handle_credentials(event)
end
local reply = st.reply(stanza):tag("credentials", { xmlns = action.attr.xmlns });
- local extras = module:get_host_items("external_service");
- local services = ( configured_services + extras ) / prepare;
+ local services = get_services();
services:filter(function (item)
return item.restricted;
end)
@@ -198,8 +203,6 @@ local function handle_credentials(event)
tonumber(service.attr.port) or 0));
end
- setmetatable(services, services_mt);
-
module:fire_event("external_service/credentials", {
origin = origin;
stanza = stanza;