aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/muc.lib.lua
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-03-20 15:22:02 -0400
committerdaurnimator <quae@daurnimator.com>2014-03-20 15:22:02 -0400
commit4b1e0493b74fa0674f550f5148aeba5cf116e269 (patch)
tree5ebf77d9fcceed6e586e540e4fb3ce5e2453c1a9 /plugins/muc/muc.lib.lua
parent46dedfa06a5a0046b34cd43a130a19a29be5c16d (diff)
downloadprosody-4b1e0493b74fa0674f550f5148aeba5cf116e269.tar.gz
prosody-4b1e0493b74fa0674f550f5148aeba5cf116e269.zip
plugins/muc/muc.lib: Add route_to_occupant function to send a stanza to all occupant sessions
Diffstat (limited to 'plugins/muc/muc.lib.lua')
-rw-r--r--plugins/muc/muc.lib.lua25
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 746814ca..af9bd162 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -96,6 +96,15 @@ function room_mt:is_locked()
return not not self.locked
end
+function room_mt:route_to_occupant(o_data, stanza)
+ local to = stanza.attr.to;
+ for jid in pairs(o_data.sessions) do
+ stanza.attr.to = jid;
+ self:_route_stanza(stanza);
+ end
+ stanza.attr.to = to;
+end
+
function room_mt:broadcast_presence(stanza, sid, code, nick)
stanza = get_filtered_presence(stanza);
local occupant = self._occupants[stanza.attr.from];
@@ -113,14 +122,9 @@ function room_mt:broadcast_presence(stanza, sid, code, nick)
end
end
function room_mt:broadcast_message(stanza, historic)
- local to = stanza.attr.to;
- for occupant, o_data in pairs(self._occupants) do
- for jid in pairs(o_data.sessions) do
- stanza.attr.to = jid;
- self:_route_stanza(stanza);
- end
+ for occupant_jid, o_data in pairs(self._occupants) do
+ self:route_to_occupant(o_data, stanza)
end
- stanza.attr.to = to;
if historic then -- add to history
return self:save_to_history(stanza)
end
@@ -660,11 +664,8 @@ function room_mt:handle_message_to_occupant(origin, stanza)
log("debug", "%s sent private message stanza to %s (%s)", from, to, o_data.jid);
stanza:tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }):up();
stanza.attr.from = current_nick;
- for jid in pairs(o_data.sessions) do
- stanza.attr.to = jid;
- self:_route_stanza(stanza);
- end
- stanza.attr.from, stanza.attr.to = from, to;
+ self:route_to_occupant(o_data, stanza)
+ stanza.attr.from = from;
return true;
end