Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 7118:dacc07833b86
MUC: Fire a muc-disco#info event like in trunk so modules can extend the reply
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 03 Feb 2016 02:07:03 +0100 |
parent | 7012:990b4ddaf582 |
child | 7120:a6afe52159f1 |
child | 7385:17929cdacec2 |
comparison
equal
deleted
inserted
replaced
7117:2b4432cc9c29 | 7118:dacc07833b86 |
---|---|
194 end | 194 end |
195 end | 195 end |
196 | 196 |
197 function room_mt:get_disco_info(stanza) | 197 function room_mt:get_disco_info(stanza) |
198 local count = 0; for _ in pairs(self._occupants) do count = count + 1; end | 198 local count = 0; for _ in pairs(self._occupants) do count = count + 1; end |
199 return st.reply(stanza):query("http://jabber.org/protocol/disco#info") | 199 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#info") |
200 :tag("identity", {category="conference", type="text", name=self:get_name()}):up() | 200 :tag("identity", {category="conference", type="text", name=self:get_name()}):up() |
201 :tag("feature", {var="http://jabber.org/protocol/muc"}):up() | 201 :tag("feature", {var="http://jabber.org/protocol/muc"}):up() |
202 :tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up() | 202 :tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up() |
203 :tag("feature", {var=self:get_moderated() and "muc_moderated" or "muc_unmoderated"}):up() | 203 :tag("feature", {var=self:get_moderated() and "muc_moderated" or "muc_unmoderated"}):up() |
204 :tag("feature", {var=self:get_members_only() and "muc_membersonly" or "muc_open"}):up() | 204 :tag("feature", {var=self:get_members_only() and "muc_membersonly" or "muc_open"}):up() |
205 :tag("feature", {var=self:get_persistent() and "muc_persistent" or "muc_temporary"}):up() | 205 :tag("feature", {var=self:get_persistent() and "muc_persistent" or "muc_temporary"}):up() |
206 :tag("feature", {var=self:get_hidden() and "muc_hidden" or "muc_public"}):up() | 206 :tag("feature", {var=self:get_hidden() and "muc_hidden" or "muc_public"}):up() |
207 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up() | 207 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up() |
208 :add_child(dataform.new({ | |
209 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" }, | |
210 { name = "muc#roominfo_description", label = "Description", value = "" }, | |
211 { name = "muc#roominfo_occupants", label = "Number of occupants", value = tostring(count) } | |
212 }):form({["muc#roominfo_description"] = self:get_description()}, 'result')) | |
213 ; | 208 ; |
209 local dataform = dataform.new({ | |
210 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" }, | |
211 { name = "muc#roominfo_description", label = "Description", value = "" }, | |
212 { name = "muc#roominfo_occupants", label = "Number of occupants", value = "" } | |
213 }); | |
214 local formdata = { | |
215 ["muc#roominfo_description"] = self:get_description(), | |
216 ["muc#roominfo_occupants"] = tostring(count), | |
217 }; | |
218 module:fire_event("muc-disco#info", { room = self, reply = reply, form = dataform, formdata = formdata }); | |
219 reply:add_child(dataform:form(formdata, 'result')) | |
220 return reply; | |
214 end | 221 end |
215 function room_mt:get_disco_items(stanza) | 222 function room_mt:get_disco_items(stanza) |
216 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items"); | 223 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items"); |
217 for room_jid in pairs(self._occupants) do | 224 for room_jid in pairs(self._occupants) do |
218 reply:tag("item", {jid = room_jid, name = room_jid:match("/(.*)")}):up(); | 225 reply:tag("item", {jid = room_jid, name = room_jid:match("/(.*)")}):up(); |