I am developing a messaging app for Android using ejabberd XMPP. App has a room chat feature (MUC). I have a question regarding MUC owner affiliation.
userA(Creator) creates a new room (MUC).
UserB joins the room and userA(Creator) grants ownership to userB.
userB revokes ownership of userA(Creator)
userA(Creator) is now none (this is the problem)
I want to know how to configure XMPP server to not allow any owner to revoke ownership of the user who created the room/MUC ?
https://xmpp.org/extensions/xep-0045.html
1条答案
按热度按时间jhiyze9q1#
You should implement a custom ejabberd module and use muc_process_iq hook. When someone tries to revoke ownership it sends an IQ stanza to MUC, You can catch it by above hook.
Your hook's callback function should be something like:
But you do not have creator jid in
MUCState
because in XMPP it does not matter!Actually there is a hack. Each affiliation can be set with a custom reason which is just a text inside
<reason>...</reason>
tag. You can access owners' affiliation reasons inMUCState
.Room creator (first owner) does not have reason in it's affiliation. So when someone is granting ownership, you can put something into 'reason' field (you need to do it in user scope, e.g.
user_send_packet
hook) and let MUC handle it and when someone is revoking ownership check if target owner has 'reason' filed or not in above function.Also there is more advanced and standard approach to do it. You can change MUC config state and add creator jid and some changes in
mod_muc_room.erl
. So you can have creator's jid inMUCState
in above function.