aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-05-06 18:37:46 +0100
committerMatthew Wild <mwild1@gmail.com>2015-05-06 18:37:46 +0100
commit1b811608357cb2b249f41672ef285b6baf332fa2 (patch)
treeb617df9bcfb77396be2e5cbae628142767cbb8f3
parentc98f87b4a77b152e7abb8a95402f1292ac937ebc (diff)
downloadprosody-1b811608357cb2b249f41672ef285b6baf332fa2.tar.gz
prosody-1b811608357cb2b249f41672ef285b6baf332fa2.zip
moduleapi: Add module:broadcast() to send a stanza to a list of JIDs
-rw-r--r--core/moduleapi.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index f3326295..c40363a1 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -10,6 +10,7 @@ local config = require "core.configmanager";
local modulemanager; -- This gets set from modulemanager
local array = require "util.array";
local set = require "util.set";
+local it = require "util.iterators";
local logger = require "util.logger";
local pluginloader = require "util.pluginloader";
local timer = require "util.timer";
@@ -362,6 +363,14 @@ function api:send(stanza)
return core_post_stanza(hosts[self.host], stanza);
end
+function api:broadcast(jids, stanza, iter)
+ for jid in (iter or it.values)(jids) do
+ local new_stanza = st.clone(stanza);
+ new_stanza.attr.to = jid;
+ core_post_stanza(hosts[self.host], new_stanza);
+ end
+end
+
function api:add_timer(delay, callback)
return timer.add_task(delay, function (t)
if self.loaded == false then return; end