Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 4170:adcfd525f329
MUC: Add option to allow participants to change the subject.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 14 Jan 2011 15:52:36 +0100 |
parent | 4055:f3adda1ed0df |
child | 4201:9a8d2baf7a9c |
comparison
equal
deleted
inserted
replaced
4169:1033729a2467 | 4170:adcfd525f329 |
---|---|
324 if self.save then self:save(true); end | 324 if self.save then self:save(true); end |
325 end | 325 end |
326 end | 326 end |
327 function room_mt:is_hidden() | 327 function room_mt:is_hidden() |
328 return self._data.hidden; | 328 return self._data.hidden; |
329 end | |
330 function room_mt:set_changesubject(changesubject) | |
331 changesubject = changesubject and true or nil; | |
332 if self._data.changesubject ~= changesubject then | |
333 self._data.changesubject = changesubject; | |
334 if self.save then self:save(true); end | |
335 end | |
336 end | |
337 function room_mt:get_changesubject() | |
338 return self._data.changesubject; | |
329 end | 339 end |
330 | 340 |
331 function room_mt:handle_to_occupant(origin, stanza) -- PM, vCards, etc | 341 function room_mt:handle_to_occupant(origin, stanza) -- PM, vCards, etc |
332 local from, to = stanza.attr.from, stanza.attr.to; | 342 local from, to = stanza.attr.from, stanza.attr.to; |
333 local room = jid_bare(to); | 343 local room = jid_bare(to); |
563 type = 'boolean', | 573 type = 'boolean', |
564 label = 'Make Room Publicly Searchable?', | 574 label = 'Make Room Publicly Searchable?', |
565 value = not self:is_hidden() | 575 value = not self:is_hidden() |
566 }, | 576 }, |
567 { | 577 { |
578 name = 'muc#roomconfig_changesubject', | |
579 type = 'boolean', | |
580 label = 'Allow Occupants to Change Subject?', | |
581 value = self:get_changesubject() | |
582 }, | |
583 { | |
568 name = 'muc#roomconfig_whois', | 584 name = 'muc#roomconfig_whois', |
569 type = 'list-single', | 585 type = 'list-single', |
570 label = 'Who May Discover Real JIDs?', | 586 label = 'Who May Discover Real JIDs?', |
571 value = { | 587 value = { |
572 { value = 'moderators', label = 'Moderators Only', default = self._data.whois == 'moderators' }, | 588 { value = 'moderators', label = 'Moderators Only', default = self._data.whois == 'moderators' }, |
635 module:log("debug", "membersonly=%s", tostring(membersonly)); | 651 module:log("debug", "membersonly=%s", tostring(membersonly)); |
636 | 652 |
637 local public = fields['muc#roomconfig_publicroom']; | 653 local public = fields['muc#roomconfig_publicroom']; |
638 dirty = dirty or (self:is_hidden() ~= (not public and true or nil)) | 654 dirty = dirty or (self:is_hidden() ~= (not public and true or nil)) |
639 | 655 |
656 local changesubject = fields['muc#roomconfig_changesubject']; | |
657 dirty = dirty or (self:get_changesubject() ~= (not changesubject and true or nil)) | |
658 module:log('debug', 'changesubject=%s', changesubject and "true" or "false") | |
659 | |
640 local whois = fields['muc#roomconfig_whois']; | 660 local whois = fields['muc#roomconfig_whois']; |
641 if not valid_whois[whois] then | 661 if not valid_whois[whois] then |
642 origin.send(st.error_reply(stanza, 'cancel', 'bad-request', "Invalid value for 'whois'")); | 662 origin.send(st.error_reply(stanza, 'cancel', 'bad-request', "Invalid value for 'whois'")); |
643 return; | 663 return; |
644 end | 664 end |
652 end | 672 end |
653 self:set_moderated(moderated); | 673 self:set_moderated(moderated); |
654 self:set_members_only(membersonly); | 674 self:set_members_only(membersonly); |
655 self:set_persistent(persistent); | 675 self:set_persistent(persistent); |
656 self:set_hidden(not public); | 676 self:set_hidden(not public); |
677 self:set_changesubject(changesubject); | |
657 | 678 |
658 if self.save then self:save(true); end | 679 if self.save then self:save(true); end |
659 origin.send(st.reply(stanza)); | 680 origin.send(st.reply(stanza)); |
660 | 681 |
661 if dirty or whois_changed then | 682 if dirty or whois_changed then |
815 else | 836 else |
816 local from = stanza.attr.from; | 837 local from = stanza.attr.from; |
817 stanza.attr.from = current_nick; | 838 stanza.attr.from = current_nick; |
818 local subject = getText(stanza, {"subject"}); | 839 local subject = getText(stanza, {"subject"}); |
819 if subject then | 840 if subject then |
820 if occupant.role == "moderator" then | 841 if occupant.role == "moderator" or |
842 ( self._data.changesubject and occupant.role == "participant" ) then -- and participant | |
821 self:set_subject(current_nick, subject); -- TODO use broadcast_message_stanza | 843 self:set_subject(current_nick, subject); -- TODO use broadcast_message_stanza |
822 else | 844 else |
823 stanza.attr.from = from; | 845 stanza.attr.from = from; |
824 origin.send(st.error_reply(stanza, "cancel", "forbidden")); | 846 origin.send(st.error_reply(stanza, "cancel", "forbidden")); |
825 end | 847 end |