MUC: Assign priorities to config form hooks so they have a consistent order on each...
[prosody.git] / plugins / muc / affiliation_notify.lib.lua
index e2ecbc3be5e994d6b5eb348c0bd5b0dddc5d7a44..7403a9ace8d79e7edd3f80917a9491fd4590c861 100644 (file)
@@ -24,7 +24,6 @@ local function set_affiliation_notify(room, affiliation_notify)
        affiliation_notify = affiliation_notify and true or nil;
        if room._data.affiliation_notify == affiliation_notify then return false; end
        room._data.affiliation_notify = affiliation_notify;
-       if room.save then room:save(true); end
        return true;
 end
 
@@ -35,11 +34,10 @@ module:hook("muc-config-form", function(event)
                label = "Notify users when their affiliation changes when they are not in the room?";
                value = get_affiliation_notify(event.room);
        });
-end);
+end, 100-11);
 
-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);