diff options
author | Kim Alvefur <zash@zash.se> | 2010-09-26 18:15:30 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2010-09-26 18:15:30 +0200 |
commit | 47cddab8023afe67adefdad70cf5b3ce1de7c704 (patch) | |
tree | 93095f8f4a7a0e2149d9bf4ae82ac5821cc1b791 /plugins/muc | |
parent | 23a72d82e1c88e27df97413bc6634e6496042d33 (diff) | |
download | prosody-47cddab8023afe67adefdad70cf5b3ce1de7c704.tar.gz prosody-47cddab8023afe67adefdad70cf5b3ce1de7c704.zip |
MUC: Added a 'Description' property (muc#roomconfig_roomdesc)
Diffstat (limited to 'plugins/muc')
-rw-r--r-- | plugins/muc/muc.lib.lua | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 5d20b78a..1359d21d 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -220,6 +220,14 @@ function room_mt:get_disco_info(stanza) :tag("feature", {var=self:is_persistent() and "muc_persistent" or "muc_temporary"}):up() :tag("feature", {var=self:is_hidden() and "muc_hidden" or "muc_public"}):up() :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up() + :tag("x", {xmlns="jabber:x:data", type="result"}) + :tag("field", {var="FORM_TYPE", type="hidden"}) + :tag("value"):text("http://jabber.org/protocol/muc#roominfo"):up() + :up() + :tag("field", {var="muc#roominfo_description", label="Description"}) + :tag("value"):text(self:get_description()):up() + :up() + :up() ; end function room_mt:get_disco_items(stanza) @@ -261,6 +269,16 @@ end function room_mt:get_name() return self._data.name; end +function room_mt:set_description(description) + if description == "" or type(description) ~= "string" then description = nil; end + if self._data.description ~= description then + self._data.description = description; + if self.save then self:save(true); end + end +end +function room_mt:get_description() + return self._data.description; +end function room_mt:set_password(password) if password == "" or type(password) ~= "string" then password = nil; end if self._data.password ~= password then @@ -511,10 +529,13 @@ function room_mt:send_form(origin, stanza) :tag("x", {xmlns='jabber:x:data', type='form'}) :tag("title"):text(title):up() :tag("instructions"):text(title):up() - :tag("field", {type='text-single', label='Room Title', var='muc#roomconfig_roomname'}) + :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up() + :tag("field", {type='text-single', label='Name', var='muc#roomconfig_roomname'}) :tag("value"):text(self:get_name() or ""):up() :up() - :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up() + :tag("field", {type='text-single', label='Description', var='muc#roomconfig_roomdesc'}) + :tag("value"):text(self:get_description() or ""):up() + :up() :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'}) :tag("value"):text(self:is_persistent() and "1" or "0"):up() :up() @@ -569,6 +590,11 @@ function room_mt:process_form(origin, stanza) self:set_name(name); end + local description = fields['muc#roomconfig_roomdesc']; + if description then + self:set_description(description); + end + local persistent = fields['muc#roomconfig_persistentroom']; if persistent == "0" or persistent == "false" then persistent = nil; elseif persistent == "1" or persistent == "true" then persistent = true; else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end |