Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 6125:4a35a0281d8a
plugins/muc/muc.lib: Send invite out from event: removes '-prepared' from event name
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Wed, 19 Mar 2014 17:33:32 -0400 |
parent | 6124:203f2b4933b0 |
child | 6126:122e0f26e8f6 |
comparison
equal
deleted
inserted
replaced
6124:203f2b4933b0 | 6125:4a35a0281d8a |
---|---|
1009 :text(_reason or "") | 1009 :text(_reason or "") |
1010 :up() | 1010 :up() |
1011 :tag('body') -- Add a plain message for clients which don't support invites | 1011 :tag('body') -- Add a plain message for clients which don't support invites |
1012 :text(_from..' invited you to the room '.._to..(_reason and (' ('.._reason..')') or "")) | 1012 :text(_from..' invited you to the room '.._to..(_reason and (' ('.._reason..')') or "")) |
1013 :up(); | 1013 :up(); |
1014 module:fire_event("muc-invite-prepared", { room = self, stanza = invite }) | 1014 module:fire_event("muc-invite", { room = self, stanza = invite, origin = origin, incoming = stanza }); |
1015 self:_route_stanza(invite); | |
1016 return true; | 1015 return true; |
1017 else | 1016 else |
1018 origin.send(st.error_reply(stanza, "cancel", "jid-malformed")); | 1017 origin.send(st.error_reply(stanza, "cancel", "jid-malformed")); |
1019 return true; | 1018 return true; |
1020 end | 1019 end |
1021 end | 1020 end |
1022 | 1021 |
1022 module:hook("muc-invite", function(event) | |
1023 event.room:_route_stanza(event.stanza); | |
1024 return true; | |
1025 end, -1) | |
1026 | |
1023 -- When an invite is sent; add an affiliation for the invitee | 1027 -- When an invite is sent; add an affiliation for the invitee |
1024 module:hook("muc-invite-prepared", function(event) | 1028 module:hook("muc-invite", function(event) |
1025 local room, stanza = event.room, event.stanza | 1029 local room, stanza = event.room, event.stanza |
1026 local invitee = stanza.attr.to | 1030 local invitee = stanza.attr.to |
1027 if room:get_members_only() and not room:get_affiliation(invitee) then | 1031 if room:get_members_only() and not room:get_affiliation(invitee) then |
1028 local from = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite").attr.from | 1032 local from = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite").attr.from |
1029 local current_nick = room:get_occupant_jid(from) | 1033 local current_nick = room:get_occupant_jid(from) |