# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1637063556 0
# Node ID 624c14b77bb47ad35a1120d7c9c856d380849d82
# Parent  0dc2c3530d64d87b964774924ced425921637d82
MUC: Switch to event.allowed signaling to block event, matching muc-pre-set-role

...and fixing the logic bug that broke everything in the previous commit.

diff -r 0dc2c3530d64 -r 624c14b77bb4 plugins/muc/muc.lib.lua
--- a/plugins/muc/muc.lib.lua	Tue Nov 16 11:41:08 2021 +0000
+++ b/plugins/muc/muc.lib.lua	Tue Nov 16 11:52:36 2021 +0000
@@ -1432,7 +1432,9 @@
 		previous_affiliation = target_affiliation;
 		data = data and data or nil; -- coerce false to nil
 	};
-	if not module:fire_event("muc-pre-set-affiliation", event_data) then
+
+	module:fire_event("muc-pre-set-affiliation", event_data);
+	if event.allowed == false then
 		local err = event_data.error or { type = "cancel", condition = "not-allowed" };
 		return nil, err.type, err.condition;
 	end