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:
my_callback(IQ, MUCState) ->
% check if it's for granting/revoking ownership
% ...
NewIQ. % or atom 'ignore'
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 in MUCState
.
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 in MUCState
in above function.