diff options
author | Matthew Wild <mwild1@gmail.com> | 2015-05-06 18:37:46 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2015-05-06 18:37:46 +0100 |
commit | 2648f37aa0c3b57f5bd5319497a79b1486e710f6 (patch) | |
tree | b617df9bcfb77396be2e5cbae628142767cbb8f3 /core/moduleapi.lua | |
parent | 53e2d9e8a3d003eb3f3218f98335f8375bfcfb09 (diff) | |
download | prosody-2648f37aa0c3b57f5bd5319497a79b1486e710f6.tar.gz prosody-2648f37aa0c3b57f5bd5319497a79b1486e710f6.zip |
moduleapi: Add module:broadcast() to send a stanza to a list of JIDs
Diffstat (limited to 'core/moduleapi.lua')
-rw-r--r-- | core/moduleapi.lua | 9 |
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 |