25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +01:00

Allow a room admin also to subscribe another JID

This commit is contained in:
Badlop 2017-04-26 01:30:12 +02:00
parent 56a4bf8f3c
commit c0eb85ce53
2 changed files with 17 additions and 2 deletions

View File

@ -24,7 +24,7 @@
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.11"}}}, {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.11"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.8"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.8"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.21"}}}, {fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.21"}}},
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "806ac5e4ebfbcf1f8f5ebe5a8458ebb7e250d501"}}, {xmpp, ".*", {git, "https://github.com/processone/xmpp", "e8dbfec277e7eb27b8130b13873b969cc346fafc"}},
{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.10"}}}, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.10"}}},
{esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.11"}}}, {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.11"}}},
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.9"}}}, {fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.9"}}},

View File

@ -3711,6 +3711,21 @@ process_iq_mucsub(_From, #iq{type = set, lang = Lang,
sub_els = [#muc_subscribe{}]}, sub_els = [#muc_subscribe{}]},
#state{just_created = false, config = #config{allow_subscription = false}}) -> #state{just_created = false, config = #config{allow_subscription = false}}) ->
{error, xmpp:err_not_allowed(<<"Subscriptions are not allowed">>, Lang)}; {error, xmpp:err_not_allowed(<<"Subscriptions are not allowed">>, Lang)};
process_iq_mucsub(From,
#iq{type = set, lang = Lang,
sub_els = [#muc_subscribe{jid = #jid{} = SubJid} = Mucsub]},
StateData) ->
FAffiliation = get_affiliation(From, StateData),
FRole = get_role(From, StateData),
if FRole == moderator; FAffiliation == owner; FAffiliation == admin ->
process_iq_mucsub(SubJid,
#iq{type = set, lang = Lang,
sub_els = [Mucsub#muc_subscribe{jid = undefined}]},
StateData);
true ->
Txt = <<"Moderator privileges required">>,
{error, xmpp:err_forbidden(Txt, Lang)}
end;
process_iq_mucsub(From, process_iq_mucsub(From,
#iq{type = set, lang = Lang, #iq{type = set, lang = Lang,
sub_els = [#muc_subscribe{nick = Nick}]} = Packet, sub_els = [#muc_subscribe{nick = Nick}]} = Packet,
@ -3748,7 +3763,7 @@ process_iq_mucsub(From, #iq{type = set, lang = Lang,
FRole = get_role(From, StateData), FRole = get_role(From, StateData),
if FRole == moderator; FAffiliation == owner; FAffiliation == admin -> if FRole == moderator; FAffiliation == owner; FAffiliation == admin ->
process_iq_mucsub(UnsubJid, process_iq_mucsub(UnsubJid,
#iq{type = set, #iq{type = set, lang = Lang,
sub_els = [#muc_unsubscribe{jid = undefined}]}, sub_els = [#muc_unsubscribe{jid = undefined}]},
StateData); StateData);
true -> true ->