Comparison

plugins/muc/muc.lib.lua @ 4266:513485a11b85

MUC: Include occupant count in room disco#info response.
author Waqas Hussain <waqas20@gmail.com>
date Sat, 07 May 2011 21:17:03 +0500
parent 4202:dff7df4a191b
child 4326:6c082bf9bf0f
comparison
equal deleted inserted replaced
4265:d56c26c258e4 4266:513485a11b85
211 self:_route_stanza(st.message({type='groupchat', from=self._data['subject_from'] or self.jid, to=to}):tag("subject"):text(self._data['subject'])); 211 self:_route_stanza(st.message({type='groupchat', from=self._data['subject_from'] or self.jid, to=to}):tag("subject"):text(self._data['subject']));
212 end 212 end
213 end 213 end
214 214
215 function room_mt:get_disco_info(stanza) 215 function room_mt:get_disco_info(stanza)
216 local count = 0; for _ in pairs(self._occupants) do count = count + 1; end
216 return st.reply(stanza):query("http://jabber.org/protocol/disco#info") 217 return st.reply(stanza):query("http://jabber.org/protocol/disco#info")
217 :tag("identity", {category="conference", type="text", name=self:get_name()}):up() 218 :tag("identity", {category="conference", type="text", name=self:get_name()}):up()
218 :tag("feature", {var="http://jabber.org/protocol/muc"}):up() 219 :tag("feature", {var="http://jabber.org/protocol/muc"}):up()
219 :tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up() 220 :tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up()
220 :tag("feature", {var=self:is_moderated() and "muc_moderated" or "muc_unmoderated"}):up() 221 :tag("feature", {var=self:is_moderated() and "muc_moderated" or "muc_unmoderated"}):up()
222 :tag("feature", {var=self:is_persistent() and "muc_persistent" or "muc_temporary"}):up() 223 :tag("feature", {var=self:is_persistent() and "muc_persistent" or "muc_temporary"}):up()
223 :tag("feature", {var=self:is_hidden() and "muc_hidden" or "muc_public"}):up() 224 :tag("feature", {var=self:is_hidden() and "muc_hidden" or "muc_public"}):up()
224 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up() 225 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up()
225 :add_child(dataform.new({ 226 :add_child(dataform.new({
226 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" }, 227 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" },
227 { name = "muc#roominfo_description", label = "Description"} 228 { name = "muc#roominfo_description", label = "Description"},
229 { name = "muc#roominfo_occupants", label = "Number of occupants", value = tostring(count) }
228 }):form({["muc#roominfo_description"] = self:get_description()}, 'result')) 230 }):form({["muc#roominfo_description"] = self:get_description()}, 'result'))
229 ; 231 ;
230 end 232 end
231 function room_mt:get_disco_items(stanza) 233 function room_mt:get_disco_items(stanza)
232 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items"); 234 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items");