25 lines
970 B
Lua
25 lines
970 B
Lua
|
-- Promotes to owner (real moderator) if the JWT has context.user.moderator = true
|
||
|
local util = module:require "util"
|
||
|
local is_admin = util.is_admin
|
||
|
local is_healthcheck_room = util.is_healthcheck_room
|
||
|
|
||
|
-- When a participant enters the room:
|
||
|
module:hook('muc-occupant-joined', function (event)
|
||
|
local room, occupant, session = event.room, event.occupant, event.origin
|
||
|
|
||
|
-- Ignores focus/healthcheck/etc.
|
||
|
if is_healthcheck_room(room.jid) or is_admin(occupant.bare_jid) then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
-- Requires moderator token and claim (accepts boolean or string "true")
|
||
|
local user = session and session.jitsi_meet_context_user
|
||
|
local has_token = session and session.auth_token
|
||
|
local wants_mod = user and (user.moderator == true or user.moderator == "true")
|
||
|
|
||
|
if has_token and wants_mod then
|
||
|
-- Assign owner affiliation -> Jicofo will see you as moderator
|
||
|
room:set_affiliation(true, occupant.bare_jid, 'owner')
|
||
|
end
|
||
|
end, 1)
|