util.encodings: Spell out all IDNA 2008 options ICU has
[prosody.git] / plugins / muc / description.lib.lua
blobeeda83d201779467bf654ef24e9b875251c320f0
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 -- Copyright (C) 2014 Daurnimator
5 --
6 -- This project is MIT/X11 licensed. Please see the
7 -- COPYING file in the source package for more information.
8 --
10 local function get_description(room)
11 return room._data.description;
12 end
14 local function set_description(room, description)
15 if description == "" then description = nil; end
16 if get_description(room) == description then return false; end
17 room._data.description = description;
18 return true;
19 end
21 local function add_disco_form(event)
22 table.insert(event.form, {
23 name = "muc#roominfo_description";
24 label = "Description";
25 value = "";
26 });
27 event.formdata["muc#roominfo_description"] = get_description(event.room);
28 end
30 local function add_form_option(event)
31 table.insert(event.form, {
32 name = "muc#roomconfig_roomdesc";
33 type = "text-single";
34 label = "Description";
35 desc = "A brief description of the room";
36 value = get_description(event.room) or "";
37 });
38 end
40 module:hook("muc-disco#info", add_disco_form);
41 module:hook("muc-config-form", add_form_option, 100-2);
43 module:hook("muc-config-submitted/muc#roomconfig_roomdesc", function(event)
44 if set_description(event.room, event.value) then
45 event.status_codes["104"] = true;
46 end
47 end);
49 return {
50 get = get_description;
51 set = set_description;