# HG changeset patch # User Matthew Wild # Date 1530962069 -3600 # Node ID 320ae6dbb2e8eea29bf4e8e8a3e4a13085b02bdb # Parent 4101bcf9639a0cd2f283b4ea3e635840623a1ef0 MUC: Add roomconfig_roomname to disco#info, and ensure it's not auto-generated diff -r 4101bcf9639a -r 320ae6dbb2e8 plugins/muc/name.lib.lua --- a/plugins/muc/name.lib.lua Sat Jul 07 12:12:36 2018 +0100 +++ b/plugins/muc/name.lib.lua Sat Jul 07 12:14:29 2018 +0100 @@ -14,24 +14,27 @@ end local function set_name(room, name) - if name == "" or name == (jid_split(room.jid)) then name = nil; end + if name == "" then name = nil; end if room._data.name == name then return false; end room._data.name = name; return true; end -module:hook("muc-disco#info", function(event) - event.reply:tag("identity", {category="conference", type="text", name=get_name(event.room)}):up(); -end); - -module:hook("muc-config-form", function(event) +local function insert_name_into_form(event); table.insert(event.form, { name = "muc#roomconfig_roomname"; type = "text-single"; label = "Name"; - value = get_name(event.room) or ""; + value = event.room._data.name; }); -end, 100-1); +end + +module:hook("muc-disco#info", function(event) + event.reply:tag("identity", {category="conference", type="text", name=get_name(event.room)}):up(); + insert_name_into_form(event); +end); + +module:hook("muc-config-form", insert_name_into_form, 100-1); module:hook("muc-config-submitted/muc#roomconfig_roomname", function(event) if set_name(event.room, event.value) then