aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/muc.lib.lua
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-04-03 18:36:28 -0400
committerdaurnimator <quae@daurnimator.com>2014-04-03 18:36:28 -0400
commit0b749352c28b79d5ebc582d479591adb8aa7ae2f (patch)
tree2fac6c76954753b958eecc717f19f9efa06034b2 /plugins/muc/muc.lib.lua
parentd9474e875f5ea22a41f081e9586840ca70739db8 (diff)
downloadprosody-0b749352c28b79d5ebc582d479591adb8aa7ae2f.tar.gz
prosody-0b749352c28b79d5ebc582d479591adb8aa7ae2f.zip
plugins/muc/muc.lib: Turn get_default_role into an event
Diffstat (limited to 'plugins/muc/muc.lib.lua')
-rw-r--r--plugins/muc/muc.lib.lua28
1 files changed, 21 insertions, 7 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index fdddcfbe..4f8aa15d 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -39,16 +39,30 @@ function room_mt:get_occupant_jid(real_jid)
end
function room_mt:get_default_role(affiliation)
- if affiliation == "owner" or affiliation == "admin" then
+ local role = module:fire_event("muc-get-default-role", {
+ room = self;
+ affiliation = affiliation;
+ affiliation_rank = valid_affiliations[affiliation or "none"];
+ });
+ return role, valid_roles[role or "none"];
+end
+module:hook("muc-get-default-role", function(event)
+ if event.affiliation_rank >= valid_affiliations.admin then
return "moderator";
- elseif affiliation == "member" then
+ elseif event.affiliation_rank >= valid_affiliations.member then
return "participant";
- elseif not affiliation then
- if not self:get_members_only() then
- return self:get_moderated() and "visitor" or "participant";
- end
end
-end
+end);
+module:hook("muc-get-default-role", function(event)
+ if not event.affiliation and event.room:get_members_only() then
+ return false;
+ end
+end);
+module:hook("muc-get-default-role", function(event)
+ if not event.affiliation then
+ return event.room:get_moderated() and "visitor" or "participant";
+ end
+end, -1);
--- Occupant functions
function room_mt:new_occupant(bare_real_jid, nick)