Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 5600:1b326a1e4da6
mod_muc: Add getter/setter for 'whois' (fixes traceback)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 18 May 2013 15:28:00 +0100 |
parent | 5580:db5d1a350cc7 |
child | 5601:f55ab5fa939f |
comparison
equal
deleted
inserted
replaced
5595:b9c836dc8f2a | 5600:1b326a1e4da6 |
---|---|
354 length = nil; | 354 length = nil; |
355 end | 355 end |
356 self._data.history_length = length; | 356 self._data.history_length = length; |
357 end | 357 end |
358 | 358 |
359 | |
360 local valid_whois = { moderators = true, anyone = true }; | |
361 | |
362 function room_mt:set_whois(whois) | |
363 if valid_whois[whois] and self._data.whois ~= whois then | |
364 self._data.whois = whois; | |
365 if self.save then self:save(true); end | |
366 end | |
367 end | |
368 | |
369 function room_mt:get_whois() | |
370 return self._data.whois; | |
371 end | |
359 | 372 |
360 local function construct_stanza_id(room, stanza) | 373 local function construct_stanza_id(room, stanza) |
361 local from_jid, to_nick = stanza.attr.from, stanza.attr.to; | 374 local from_jid, to_nick = stanza.attr.from, stanza.attr.to; |
362 local from_nick = room._jid_nick[from_jid]; | 375 local from_nick = room._jid_nick[from_jid]; |
363 local occupant = room._occupants[to_nick]; | 376 local occupant = room._occupants[to_nick]; |
659 } | 672 } |
660 }); | 673 }); |
661 return module:fire_event("muc-config-form", { room = self, form = form }) or form; | 674 return module:fire_event("muc-config-form", { room = self, form = form }) or form; |
662 end | 675 end |
663 | 676 |
664 local valid_whois = { moderators = true, anyone = true }; | |
665 | |
666 function room_mt:process_form(origin, stanza) | 677 function room_mt:process_form(origin, stanza) |
667 local query = stanza.tags[1]; | 678 local query = stanza.tags[1]; |
668 local form; | 679 local form; |
669 for _, tag in ipairs(query.tags) do if tag.name == "x" and tag.attr.xmlns == "jabber:x:data" then form = tag; break; end end | 680 for _, tag in ipairs(query.tags) do if tag.name == "x" and tag.attr.xmlns == "jabber:x:data" then form = tag; break; end end |
670 if not form then origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); return; end | 681 if not form then origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); return; end |
706 if next(changed) then | 717 if next(changed) then |
707 local msg = st.message({type='groupchat', from=self.jid}) | 718 local msg = st.message({type='groupchat', from=self.jid}) |
708 :tag('x', {xmlns='http://jabber.org/protocol/muc#user'}):up() | 719 :tag('x', {xmlns='http://jabber.org/protocol/muc#user'}):up() |
709 :tag('status', {code = '104'}):up(); | 720 :tag('status', {code = '104'}):up(); |
710 if changed.whois then | 721 if changed.whois then |
711 local code = (whois == 'moderators') and "173" or "172"; | 722 local code = (self:get_whois() == 'moderators') and "173" or "172"; |
712 msg.tags[1]:tag('status', {code = code}):up(); | 723 msg.tags[1]:tag('status', {code = code}):up(); |
713 end | 724 end |
714 self:broadcast_message(msg, false) | 725 self:broadcast_message(msg, false) |
715 end | 726 end |
716 end | 727 end |