# HG changeset patch # User Kim Alvefur # Date 1568733755 -7200 # Node ID 11ebf1da416b30b9553b54615c67b7f66d1e2396 # Parent b8bcea17ccd6049ebba4c06aa2eaedaefc406211 mod_muc_webchat_url: Don't save templated value This prevents changing of other settings without touching the webchat URL from saving the template value. Otherwise the URL will still be advertised when configuring members-only or hidden. diff -r b8bcea17ccd6 -r 11ebf1da416b mod_muc_webchat_url/mod_muc_webchat_url.lua --- a/mod_muc_webchat_url/mod_muc_webchat_url.lua Tue Sep 17 17:12:59 2019 +0200 +++ b/mod_muc_webchat_url/mod_muc_webchat_url.lua Tue Sep 17 17:22:35 2019 +0200 @@ -3,11 +3,7 @@ local webchat_baseurl = module:get_option_string("muc_webchat_baseurl", nil); -local function get_webchat_url(room) - local webchat_url = room._data.webchat_url; - if webchat_url then -- explicitly configured - return webchat_url; - end +local function get_default_url(room) if not webchat_baseurl then -- no template return nil; @@ -23,6 +19,13 @@ })); end +local function get_webchat_url(room) + local webchat_url = room._data.webchat_url; + if webchat_url then -- explicitly configured + return webchat_url; + end +end + module:hook("muc-config-form", function(event) local room, form = event.room, event.form; table.insert(form, { @@ -36,8 +39,12 @@ module:hook("muc-config-submitted", function(event) local room, fields, changed = event.room, event.fields, event.changed; local new = fields["muc#roomconfig_webchat_url"]; - if new ~= room._data.webchat_url then - room._data.webchat_url = new; + if new ~= get_webchat_url(room) then + if new == get_default_url(room) then + room._data.webchat_url = nil; + else + room._data.webchat_url = new; + end if type(changed) == "table" then changed["muc#roomconfig_webchat_url"] = true; else