Comparison

plugins/muc/muc.lib.lua @ 6118:aae3d6daa50d

plugins/muc/muc.lib: Fetch config via accessors instead of using `_data`
author daurnimator <quae@daurnimator.com>
date Wed, 19 Mar 2014 14:39:31 -0400
parent 6117:d7ade0b00ec5
child 6119:c13f5d6b9b16
comparison
equal deleted inserted replaced
6117:d7ade0b00ec5 6118:aae3d6daa50d
230 :tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up() 230 :tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up()
231 :tag("feature", {var=self:get_moderated() and "muc_moderated" or "muc_unmoderated"}):up() 231 :tag("feature", {var=self:get_moderated() and "muc_moderated" or "muc_unmoderated"}):up()
232 :tag("feature", {var=self:get_members_only() and "muc_membersonly" or "muc_open"}):up() 232 :tag("feature", {var=self:get_members_only() and "muc_membersonly" or "muc_open"}):up()
233 :tag("feature", {var=self:get_persistent() and "muc_persistent" or "muc_temporary"}):up() 233 :tag("feature", {var=self:get_persistent() and "muc_persistent" or "muc_temporary"}):up()
234 :tag("feature", {var=self:get_hidden() and "muc_hidden" or "muc_public"}):up() 234 :tag("feature", {var=self:get_hidden() and "muc_hidden" or "muc_public"}):up()
235 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up() 235 :tag("feature", {var=self:get_whois() ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up()
236 :add_child(dataform.new({ 236 :add_child(dataform.new({
237 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" }, 237 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" },
238 { name = "muc#roominfo_description", label = "Description", value = "" }, 238 { name = "muc#roominfo_description", label = "Description", value = "" },
239 { name = "muc#roominfo_occupants", label = "Number of occupants", value = tostring(count) } 239 { name = "muc#roominfo_occupants", label = "Number of occupants", value = tostring(count) }
240 }):form({["muc#roominfo_description"] = self:get_description()}, 'result')) 240 }):form({["muc#roominfo_description"] = self:get_description()}, 'result'))
486 :tag("item", {affiliation=affiliation or "none", role=role or "none"}):up(); 486 :tag("item", {affiliation=affiliation or "none", role=role or "none"}):up();
487 if not is_merge then 487 if not is_merge then
488 self:broadcast_except_nick(pr, to); 488 self:broadcast_except_nick(pr, to);
489 end 489 end
490 pr:tag("status", {code='110'}):up(); 490 pr:tag("status", {code='110'}):up();
491 if self._data.whois == 'anyone' then 491 if self:get_whois() == 'anyone' then
492 pr:tag("status", {code='100'}):up(); 492 pr:tag("status", {code='100'}):up();
493 end 493 end
494 if self.locked then 494 if self.locked then
495 pr:tag("status", {code='201'}):up(); 495 pr:tag("status", {code='201'}):up();
496 end 496 end
659 :add_child(self:get_form_layout(stanza.attr.from):form()) 659 :add_child(self:get_form_layout(stanza.attr.from):form())
660 ); 660 );
661 end 661 end
662 662
663 function room_mt:get_form_layout(actor) 663 function room_mt:get_form_layout(actor)
664 local whois = self:get_whois()
664 local form = dataform.new({ 665 local form = dataform.new({
665 title = "Configuration for "..self.jid, 666 title = "Configuration for "..self.jid,
666 instructions = "Complete and submit this form to configure the room.", 667 instructions = "Complete and submit this form to configure the room.",
667 { 668 {
668 name = 'FORM_TYPE', 669 name = 'FORM_TYPE',
702 { 703 {
703 name = 'muc#roomconfig_whois', 704 name = 'muc#roomconfig_whois',
704 type = 'list-single', 705 type = 'list-single',
705 label = 'Who May Discover Real JIDs?', 706 label = 'Who May Discover Real JIDs?',
706 value = { 707 value = {
707 { value = 'moderators', label = 'Moderators Only', default = self._data.whois == 'moderators' }, 708 { value = 'moderators', label = 'Moderators Only', default = whois == 'moderators' },
708 { value = 'anyone', label = 'Anyone', default = self._data.whois == 'anyone' } 709 { value = 'anyone', label = 'Anyone', default = whois == 'anyone' }
709 } 710 }
710 }, 711 },
711 { 712 {
712 name = 'muc#roomconfig_roomsecret', 713 name = 'muc#roomconfig_roomsecret',
713 type = 'text-private', 714 type = 'text-private',
950 local from = stanza.attr.from; 951 local from = stanza.attr.from;
951 stanza.attr.from = current_nick; 952 stanza.attr.from = current_nick;
952 local subject = stanza:get_child_text("subject"); 953 local subject = stanza:get_child_text("subject");
953 if subject then 954 if subject then
954 if occupant.role == "moderator" or 955 if occupant.role == "moderator" or
955 ( self._data.changesubject and occupant.role == "participant" ) then -- and participant 956 ( self:get_changesubject() and occupant.role == "participant" ) then -- and participant
956 self:set_subject(current_nick, subject); 957 self:set_subject(current_nick, subject);
957 else 958 else
958 stanza.attr.from = from; 959 stanza.attr.from = from;
959 origin.send(st.error_reply(stanza, "auth", "forbidden")); 960 origin.send(st.error_reply(stanza, "auth", "forbidden"));
960 end 961 end
1212 local muc_child; 1213 local muc_child;
1213 if stanza.name == "presence" then 1214 if stanza.name == "presence" then
1214 local to_occupant = self._occupants[self._jid_nick[stanza.attr.to]]; 1215 local to_occupant = self._occupants[self._jid_nick[stanza.attr.to]];
1215 local from_occupant = self._occupants[stanza.attr.from]; 1216 local from_occupant = self._occupants[stanza.attr.from];
1216 if to_occupant and from_occupant then 1217 if to_occupant and from_occupant then
1217 if self._data.whois == 'anyone' then 1218 if self:get_whois() == 'anyone' then
1218 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); 1219 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user");
1219 else 1220 else
1220 if to_occupant.role == "moderator" or jid_bare(to_occupant.jid) == jid_bare(from_occupant.jid) then 1221 if to_occupant.role == "moderator" or jid_bare(to_occupant.jid) == jid_bare(from_occupant.jid) then
1221 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); 1222 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user");
1222 end 1223 end