Determine room initiator in muc-occupant-pre-join

I have set up secure domain and was wondering whether it is possible to determine whether the current
joiner/occupant is the one that created the room. I hope that the affiliation would bet set at this stage, but it is nil, when I use this hook.

module:hook("muc-occupant-pre-join", function (event)
  local room, stanza = event.room, event.stanza;
  local affiliation = room:get_affiliation(stanza.attr.from);
  local user, domain, res = jid.split(event.stanza.attr.from);
  log("debug", "2--------------> user %s domain %s res %s aff %s",  tostring(user),tostring(domain),tostring(res),, affiliation)
end)

Also the domain at this stage seems to already be change to “guest.example.com”. For the focus user on the other hand affiliation is set and auth.example.com is used as domain.

Is there a way to determine whether this user actually created the room or was authenticated by the secure domain?

There are events when room is or pre cretaed … maybe if in occupant pre join if this is the first occupant that is not focus, than that is the one creating it.
Normally jicofo creates rooms and joins first.

Thanks for the hint. Indeed that might work and I will try that.

It works if the user created the room. but on second thought it is not what I need:
Iif there is a conference and the moderator leaves and rejoins but at least one participant stays, then this kind of identification fails as there is already somebody in the conference.

What I really need is to determine whether a user joining is authenticated with the secure domain.

In occupant pre join you can check the domain part of the jid to distinguish users.

See above, I already tried that. The jid is on the guest.example.com domain.

I did spend some time reading the code of prosody and jicofo (not very thoroughly, though) and it seems to go like this for secure domain:

  • When we open a room jifo checks with prosody that the user is authenticated. Here we use jid user@example.com. In the sessio ID and JID are the same:

    Jicofo 2020-05-29 12:41:52.312 INFO: [442] org.jitsi.jicofo.auth.AbstractAuthAuthority.log() Authentication session created for usr@example.com SID: 944fd822-4610-4734-884e-8b96abcfb3e8
    Jicofo 2020-05-29 12:41:52.312 INFO: [442] org.jitsi.jicofo.auth.AbstractAuthAuthority.log() Authenticated jid: blattms@example.com/afvVWOjg with session: AuthSession[ID=user@example.com, JID=user@example.com/afvVWOjg, ID=944fd822-4610-4734-884e-8b96abcfb3e8, MUID=8872f9de62cce79ecb27144937e093e1, LIFE_TM_SEC=0, R=applicablepracticesdisagreein@conference.test.eichstaett.social]@1567016946
    Jicofo 2020-05-29 12:41:52.312 INFO: [442] org.jitsi.jicofo.auth.AbstractAuthAuthority.log() Jid user@example.com/afvVWOjg authenticated as: user@example.com

  • focus creates and joins the room

    Jicofo 2020-05-29 12:41:52.313 INFO: [442] org.jitsi.jicofo.FocusManager.log() Created new focus for applicablepracticesdisagreein@conference.example.coml@auth.example.com. Conference count 2,options: channelLastN=-1 enableLipSync=false openSctp=true disableRtx=false
    Jicofo 2020-05-29 12:41:52.314 INFO: [442] org.jitsi.jicofo.JitsiMeetConferenceImpl.log() Joining the room: applicablepracticesdisagreein@conference.example.com

  • Now the user joins the room with jid fzafpkrzcb3v51s6@guest.example.com. At least in the authentication session the ID ist still the same as before. I just do not see whether this is actually available in prosody:

    Jicofo 2020-05-29 12:41:52.482 INFO: [443] org.jitsi.jicofo.auth.AbstractAuthAuthority.log() Authenticated jid: fzafpkrzcb3v51s6@guest.example.com/JEVvluRL with session: AuthSession[ID=user@example.com, JID=fzafpkrzcb3v51s6@guest.example.com/JEVvluRL, SID=944fd822-4610-4734-884e-8b96abcfb3e8, MUID=8872f9de62cce79ecb27144937e093e1, LIFE_TM_SEC=0, R=applicablepracticesdisagreein@conference.example.com]@1567016946
    Jicofo 2020-05-29 12:41:52.482 INFO: [443] org.jitsi.jicofo.auth.AbstractAuthAuthority.log() Jid fzafpkrzcb3v51s6@guest.example.com/JEVvluRL authenticated as: user@example.com
    Jicofo 2020-05-29 12:41:52.545 INFO: [31] org.jitsi.jicofo.ChatRoomRoleAndPresence.log() Chat room event ChatRoomMemberPresenceChangeEvent[type=MemberJoined sourceRoom=org.jitsi.impl.protocol.xmpp.ChatRoomImpl@6e534388 member=ChatMember[applicablepracticesdisagreein@conference.example.com/c8f5a139, jid: null]@130610316]
    Jicofo 2020-05-29 12:41:52.548 INFO: [31] org.jitsi.jicofo.JitsiMeetConferenceImpl.log() Member applicablepracticesdisagreein@conference.example.com/c8f5a139 joined.

I also assume that it is jicofo that decides who becomes moderator and passes that information on to prosody. Hence there really seems to be now way to determine whether someon joining the room in prosody was authenticated before and with which jid.