Diff

plugins/muc/muc.lib.lua @ 6204:c3254827698d

plugins/muc/muc.lib: Move description functions out to own file
author daurnimator <quae@daurnimator.com>
date Wed, 02 Apr 2014 15:14:52 -0400
parent 6203:b6ffce01e6cf
child 6206:f937bb5c83c3
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Wed Apr 02 11:35:00 2014 -0400
+++ b/plugins/muc/muc.lib.lua	Wed Apr 02 15:14:52 2014 -0400
@@ -430,9 +430,6 @@
 	event.reply:tag("feature", {var = event.room:get_whois() ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up();
 end);
 module:hook("muc-disco#info", function(event)
-	table.insert(event.form, { name = "muc#roominfo_description", label = "Description", value = event.room:get_description() });
-end);
-module:hook("muc-disco#info", function(event)
 	local count = 0; for _ in event.room:each_occupant() do count = count + 1; end
 	table.insert(event.form, { name = "muc#roominfo_occupants", label = "Number of occupants", value = tostring(count) });
 end);
@@ -495,16 +492,6 @@
 function room_mt:get_name()
 	return self._data.name or jid_split(self.jid);
 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
@@ -928,14 +915,6 @@
 end);
 module:hook("muc-config-form", function(event)
 	table.insert(event.form, {
-		name = 'muc#roomconfig_roomdesc',
-		type = 'text-single',
-		label = 'Description',
-		value = event.room:get_description() or "",
-	});
-end);
-module:hook("muc-config-form", function(event)
-	table.insert(event.form, {
 		name = 'muc#roomconfig_persistentroom',
 		type = 'boolean',
 		label = 'Make Room Persistent?',
@@ -1050,9 +1029,6 @@
 	event.update_option("name", "muc#roomconfig_roomname");
 end);
 module:hook("muc-config-submitted", function(event)
-	event.update_option("description", "muc#roomconfig_roomdesc");
-end);
-module:hook("muc-config-submitted", function(event)
 	event.update_option("persistent", "muc#roomconfig_persistentroom");
 end);
 module:hook("muc-config-submitted", function(event)
@@ -1558,6 +1534,10 @@
 	return true;
 end
 
+local description = module:require "muc/description";
+room_mt.get_description = description.get;
+room_mt.set_description = description.set;
+
 local _M = {}; -- module "muc"
 
 function _M.new_room(jid, config)