aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-12-11 15:33:58 +0000
committerMatthew Wild <mwild1@gmail.com>2015-12-11 15:33:58 +0000
commit08583d3855eb35d5758e3df47272f7296728a0b3 (patch)
tree9f64953414397f4188a3542caae8a9df40ca4db5 /plugins/muc
parente133554b2134bf79ca5683d5c2321ad57ec2dfad (diff)
downloadprosody-08583d3855eb35d5758e3df47272f7296728a0b3.tar.gz
prosody-08583d3855eb35d5758e3df47272f7296728a0b3.zip
MUC: Update all config form handlers to take advantage of the new per-option events
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/affiliation_notify.lib.lua5
-rw-r--r--plugins/muc/description.lib.lua5
-rw-r--r--plugins/muc/hidden.lib.lua5
-rw-r--r--plugins/muc/history.lib.lua9
-rw-r--r--plugins/muc/members_only.lib.lua5
-rw-r--r--plugins/muc/moderated.lib.lua5
-rw-r--r--plugins/muc/name.lib.lua5
-rw-r--r--plugins/muc/password.lib.lua5
-rw-r--r--plugins/muc/persistent.lib.lua5
-rw-r--r--plugins/muc/subject.lib.lua5
-rw-r--r--plugins/muc/whois.lib.lua5
11 files changed, 25 insertions, 34 deletions
diff --git a/plugins/muc/affiliation_notify.lib.lua b/plugins/muc/affiliation_notify.lib.lua
index e2ecbc3b..0b9ab325 100644
--- a/plugins/muc/affiliation_notify.lib.lua
+++ b/plugins/muc/affiliation_notify.lib.lua
@@ -37,9 +37,8 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/description.lib.lua b/plugins/muc/description.lib.lua
index 30852922..c4b1bd09 100644
--- a/plugins/muc/description.lib.lua
+++ b/plugins/muc/description.lib.lua
@@ -30,9 +30,8 @@ end
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);
diff --git a/plugins/muc/hidden.lib.lua b/plugins/muc/hidden.lib.lua
index 5ce43db8..35ca3026 100644
--- a/plugins/muc/hidden.lib.lua
+++ b/plugins/muc/hidden.lib.lua
@@ -28,9 +28,8 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/history.lib.lua b/plugins/muc/history.lib.lua
index d685abf2..65b1a31f 100644
--- a/plugins/muc/history.lib.lua
+++ b/plugins/muc/history.lib.lua
@@ -23,7 +23,9 @@ local function get_historylength(room)
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 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/members_only.lib.lua b/plugins/muc/members_only.lib.lua
index 90e91617..5e29a68d 100644
--- a/plugins/muc/members_only.lib.lua
+++ b/plugins/muc/members_only.lib.lua
@@ -61,9 +61,8 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/moderated.lib.lua b/plugins/muc/moderated.lib.lua
index c375b7ad..26dcb058 100644
--- a/plugins/muc/moderated.lib.lua
+++ b/plugins/muc/moderated.lib.lua
@@ -32,9 +32,8 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/name.lib.lua b/plugins/muc/name.lib.lua
index 49d12467..d9bfc4cf 100644
--- a/plugins/muc/name.lib.lua
+++ b/plugins/muc/name.lib.lua
@@ -34,9 +34,8 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/password.lib.lua b/plugins/muc/password.lib.lua
index 48486d73..8c33aa9a 100644
--- a/plugins/muc/password.lib.lua
+++ b/plugins/muc/password.lib.lua
@@ -34,9 +34,8 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/persistent.lib.lua b/plugins/muc/persistent.lib.lua
index ccf6fffe..a72bcbb5 100644
--- a/plugins/muc/persistent.lib.lua
+++ b/plugins/muc/persistent.lib.lua
@@ -28,9 +28,8 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/subject.lib.lua b/plugins/muc/subject.lib.lua
index d1895b4d..0b4e6fd6 100644
--- a/plugins/muc/subject.lib.lua
+++ b/plugins/muc/subject.lib.lua
@@ -38,9 +38,8 @@ module:hook("muc-config-form", function(event)
});
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);
diff --git a/plugins/muc/whois.lib.lua b/plugins/muc/whois.lib.lua
index f89e6087..a8e1f8d4 100644
--- a/plugins/muc/whois.lib.lua
+++ b/plugins/muc/whois.lib.lua
@@ -41,9 +41,8 @@ module:hook("muc-config-form", function(event)
});
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