Software /
code /
prosody
Changeset
6991:84e01dbb739e
MUC: Update all config form handlers to take advantage of the new per-option events
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 11 Dec 2015 15:33:58 +0000 |
parents | 6990:f476e2497568 |
children | 7003:4aa5f6896057 |
files | plugins/muc/affiliation_notify.lib.lua plugins/muc/description.lib.lua plugins/muc/hidden.lib.lua plugins/muc/history.lib.lua plugins/muc/members_only.lib.lua plugins/muc/moderated.lib.lua plugins/muc/name.lib.lua plugins/muc/password.lib.lua plugins/muc/persistent.lib.lua plugins/muc/subject.lib.lua plugins/muc/whois.lib.lua |
diffstat | 11 files changed, 25 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/muc/affiliation_notify.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/affiliation_notify.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -37,9 +37,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_affiliationnotify"]; - if new ~= nil and set_affiliation_notify(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_affiliationnotify", function(event) + if set_affiliation_notify(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/description.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/description.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -30,9 +30,8 @@ module:hook("muc-disco#info", add_form_option); module:hook("muc-config-form", add_form_option); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_roomdesc"]; - if new ~= nil and set_description(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_roomdesc", function(event) + if set_description(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/hidden.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/hidden.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -28,9 +28,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_publicroom"]; - if new ~= nil and set_hidden(event.room, not new) then +module:hook("muc-config-submitted/muc#roomconfig_publicroom", function(event) + if set_hidden(event.room, not event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/history.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/history.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -23,7 +23,9 @@ end local function set_historylength(room, length) - length = assert(tonumber(length), "Length not a valid number"); + if length then + length = assert(tonumber(length), "Length not a valid number"); + end if length == default_history_length then length = nil; end room._data.history_length = length; return true; @@ -38,9 +40,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_historylength"]; - if new ~= nil and set_historylength(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_historylength", function(event) + if set_historylength(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/members_only.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/members_only.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -61,9 +61,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_membersonly"]; - if new ~= nil and set_members_only(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_membersonly", function(event) + if set_members_only(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/moderated.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/moderated.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -32,9 +32,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_moderatedroom"]; - if new ~= nil and set_moderated(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_moderatedroom", function(event) + if set_moderated(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/name.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/name.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -34,9 +34,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_roomname"]; - if new ~= nil and set_name(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_roomname", function(event) + if set_name(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/password.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/password.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -34,9 +34,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_roomsecret"]; - if new ~= nil and set_password(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_roomsecret", function(event) + if set_password(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/persistent.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/persistent.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -28,9 +28,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_persistentroom"]; - if new ~= nil and set_persistent(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_persistentroom", function(event) + if set_persistent(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/subject.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/subject.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -38,9 +38,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_changesubject"]; - if new ~= nil and set_changesubject(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_changesubject", function(event) + if set_changesubject(event.room, event.value) then event.status_codes["104"] = true; end end);
--- a/plugins/muc/whois.lib.lua Fri Dec 11 15:27:01 2015 +0000 +++ b/plugins/muc/whois.lib.lua Fri Dec 11 15:33:58 2015 +0000 @@ -41,9 +41,8 @@ }); end); -module:hook("muc-config-submitted", function(event) - local new = event.fields["muc#roomconfig_whois"]; - if new ~= nil and set_whois(event.room, new) then +module:hook("muc-config-submitted/muc#roomconfig_whois", function(event) + if set_whois(event.room, event.value) then local code = (new == 'moderators') and "173" or "172"; event.status_codes[code] = true; end