Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local LOGLEVEL = "info"
- local is_admin = require "core.usermanager".is_admin
- local is_healthcheck_room = module:require "util".is_healthcheck_room
- module:log(LOGLEVEL, "loaded")
- local function _is_admin(jid)
- return is_admin(jid, module.host)
- end
- module:hook("muc-occupant-joined", function (event)
- local room, occupant = event.room, event.occupant
- if is_healthcheck_room(room.jid) or _is_admin(occupant.jid) then
- module:log(LOGLEVEL, "skip affiliation, %s", occupant.jid)
- return
- end
- if not event.origin.auth_token then
- module:log(LOGLEVEL, "skip affiliation, no token")
- return
- end
- local affiliation = "member"
- local context_user = event.origin.jitsi_meet_context_user
- if context_user then
- local jid_split = import("util.jid", "prepped_split");
- local room_name = jid_split(room.jid);
- module:log("info", "Room name: %s", room_name)
- local email_without_at = string.gsub(context_user["email"], "@", "");
- if string.find(room_name, "^" .. email_without_at) ~= nil then
- affiliation = "owner"
- end
- end
- module:log(LOGLEVEL, "affiliation: %s", affiliation)
- room:set_affiliation(true, occupant.bare_jid, affiliation)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement