From 177d5fec862bb6b88c0d52b2592c75647a0eb954 Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 13 Apr 2017 22:37:39 +0200 Subject: [PATCH] Allow a room admin to unsubscribe another JID --- src/mod_muc_room.erl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index a1817a631..426b28a4e 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -3741,6 +3741,19 @@ process_iq_mucsub(From, SD2 = StateData#state{config = (StateData#state.config)#config{allow_subscription = true}}, add_new_user(From, Nick, Packet, SD2) end; +process_iq_mucsub(From, #iq{type = set, lang = Lang, + sub_els = [#muc_unsubscribe{jid = UnsubJid}]}, + StateData) when UnsubJid /= <<>> -> + FAffiliation = get_affiliation(From, StateData), + FRole = get_role(From, StateData), + if FRole == moderator; FAffiliation == owner; FAffiliation == admin -> + FromUnsub = jid:from_string(UnsubJid), + process_iq_mucsub(FromUnsub, #iq{type = set, sub_els = [#muc_unsubscribe{jid = <<>>}]}, + StateData); + true -> + Txt = <<"Moderator privileges required">>, + {error, xmpp:err_forbidden(Txt, Lang)} + end; process_iq_mucsub(From, #iq{type = set, sub_els = [#muc_unsubscribe{}]}, StateData) -> LBareJID = jid:tolower(jid:remove_resource(From)),