Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 6209:cc00e78e6a31
plugins/muc: Move name functions to seperate module
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Wed, 02 Apr 2014 17:02:07 -0400 |
| parents | d724289a5226 |
| children | a4d26656df04 |
comparison
equal
deleted
inserted
replaced
| 6208:d724289a5226 | 6209:cc00e78e6a31 |
|---|---|
| 392 module:fire_event("muc-disco#info", {room = self; reply = reply; form = form;}); | 392 module:fire_event("muc-disco#info", {room = self; reply = reply; form = form;}); |
| 393 reply:add_child(form:form(nil, "result")); | 393 reply:add_child(form:form(nil, "result")); |
| 394 return reply; | 394 return reply; |
| 395 end | 395 end |
| 396 module:hook("muc-disco#info", function(event) | 396 module:hook("muc-disco#info", function(event) |
| 397 event.reply:tag("identity", {category="conference", type="text", name=event.room:get_name()}):up(); | |
| 398 end); | |
| 399 module:hook("muc-disco#info", function(event) | |
| 400 event.reply:tag("feature", {var = "http://jabber.org/protocol/muc"}):up(); | 397 event.reply:tag("feature", {var = "http://jabber.org/protocol/muc"}):up(); |
| 401 end); | 398 end); |
| 402 module:hook("muc-disco#info", function(event) | 399 module:hook("muc-disco#info", function(event) |
| 403 event.reply:tag("feature", {var = event.room:get_moderated() and "muc_moderated" or "muc_unmoderated"}):up(); | 400 event.reply:tag("feature", {var = event.room:get_moderated() and "muc_moderated" or "muc_unmoderated"}):up(); |
| 404 end); | 401 end); |
| 465 :tag("status", {code = "307"}) | 462 :tag("status", {code = "307"}) |
| 466 self:publicise_occupant_status(occupant, x); | 463 self:publicise_occupant_status(occupant, x); |
| 467 return true; | 464 return true; |
| 468 end | 465 end |
| 469 | 466 |
| 470 function room_mt:set_name(name) | |
| 471 if name == "" or type(name) ~= "string" or name == (jid_split(self.jid)) then name = nil; end | |
| 472 if self._data.name ~= name then | |
| 473 self._data.name = name; | |
| 474 if self.save then self:save(true); end | |
| 475 end | |
| 476 end | |
| 477 function room_mt:get_name() | |
| 478 return self._data.name or jid_split(self.jid); | |
| 479 end | |
| 480 function room_mt:set_moderated(moderated) | 467 function room_mt:set_moderated(moderated) |
| 481 moderated = moderated and true or nil; | 468 moderated = moderated and true or nil; |
| 482 if self._data.moderated ~= moderated then | 469 if self._data.moderated ~= moderated then |
| 483 self._data.moderated = moderated; | 470 self._data.moderated = moderated; |
| 484 if self.save then self:save(true); end | 471 if self.save then self:save(true); end |
| 851 }); | 838 }); |
| 852 return module:fire_event("muc-config-form", { room = self, actor = actor, form = form }) or form; | 839 return module:fire_event("muc-config-form", { room = self, actor = actor, form = form }) or form; |
| 853 end | 840 end |
| 854 module:hook("muc-config-form", function(event) | 841 module:hook("muc-config-form", function(event) |
| 855 table.insert(event.form, { | 842 table.insert(event.form, { |
| 856 name = 'muc#roomconfig_roomname', | |
| 857 type = 'text-single', | |
| 858 label = 'Name', | |
| 859 value = event.room:get_name() or "", | |
| 860 }); | |
| 861 end); | |
| 862 module:hook("muc-config-form", function(event) | |
| 863 table.insert(event.form, { | |
| 864 name = 'muc#roomconfig_persistentroom', | 843 name = 'muc#roomconfig_persistentroom', |
| 865 type = 'boolean', | 844 type = 'boolean', |
| 866 label = 'Make Room Persistent?', | 845 label = 'Make Room Persistent?', |
| 867 value = event.room:get_persistent() | 846 value = event.room:get_persistent() |
| 868 }); | 847 }); |
| 958 else | 937 else |
| 959 origin.send(st.error_reply(stanza, "cancel", "bad-request", "Not a submitted form")); | 938 origin.send(st.error_reply(stanza, "cancel", "bad-request", "Not a submitted form")); |
| 960 end | 939 end |
| 961 return true; | 940 return true; |
| 962 end | 941 end |
| 963 module:hook("muc-config-submitted", function(event) | |
| 964 event.update_option("name", "muc#roomconfig_roomname"); | |
| 965 end); | |
| 966 module:hook("muc-config-submitted", function(event) | 942 module:hook("muc-config-submitted", function(event) |
| 967 event.update_option("persistent", "muc#roomconfig_persistentroom"); | 943 event.update_option("persistent", "muc#roomconfig_persistentroom"); |
| 968 end); | 944 end); |
| 969 module:hook("muc-config-submitted", function(event) | 945 module:hook("muc-config-submitted", function(event) |
| 970 event.update_option("moderated", "muc#roomconfig_moderatedroom"); | 946 event.update_option("moderated", "muc#roomconfig_moderatedroom"); |
| 1455 self:save_occupant(occupant); | 1431 self:save_occupant(occupant); |
| 1456 self:publicise_occupant_status(occupant, x, actor, reason); | 1432 self:publicise_occupant_status(occupant, x, actor, reason); |
| 1457 return true; | 1433 return true; |
| 1458 end | 1434 end |
| 1459 | 1435 |
| 1436 local name = module:require "muc/name"; | |
| 1437 room_mt.get_name = name.get; | |
| 1438 room_mt.set_name = name.set; | |
| 1439 | |
| 1460 local description = module:require "muc/description"; | 1440 local description = module:require "muc/description"; |
| 1461 room_mt.get_description = description.get; | 1441 room_mt.get_description = description.get; |
| 1462 room_mt.set_description = description.set; | 1442 room_mt.set_description = description.set; |
| 1463 | 1443 |
| 1464 local password = module:require "muc/password"; | 1444 local password = module:require "muc/password"; |
