mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Add hooks for tracking mucsub subscriptions changes
This commit is contained in:
parent
009b9a1fd0
commit
c96a925fde
@ -1688,7 +1688,8 @@ update_online_user(JID, #user{nick = Nick} = User, StateData) ->
|
||||
end,
|
||||
NewStateData.
|
||||
|
||||
set_subscriber(JID, Nick, Nodes, StateData) ->
|
||||
set_subscriber(JID, Nick, Nodes,
|
||||
#state{room = Room, host = Host, server_host = ServerHost} = StateData) ->
|
||||
BareJID = case JID of
|
||||
#jid{} -> jid:remove_resource(JID);
|
||||
_ ->
|
||||
@ -1707,7 +1708,8 @@ set_subscriber(JID, Nick, Nodes, StateData) ->
|
||||
store_room(NewStateData, [{add_subscription, BareJID, Nick, Nodes}]),
|
||||
case not maps:is_key(LBareJID, StateData#state.subscribers) of
|
||||
true ->
|
||||
send_subscriptions_change_notifications(BareJID, Nick, subscribe, NewStateData);
|
||||
send_subscriptions_change_notifications(BareJID, Nick, subscribe, NewStateData),
|
||||
ejabberd_hooks:run(muc_subscribed, ServerHost, [ServerHost, Room, Host, BareJID]);
|
||||
_ ->
|
||||
ok
|
||||
end,
|
||||
@ -4056,7 +4058,7 @@ process_iq_mucsub(From, #iq{type = set, lang = Lang,
|
||||
{error, xmpp:err_forbidden(Txt, Lang)}
|
||||
end;
|
||||
process_iq_mucsub(From, #iq{type = set, sub_els = [#muc_unsubscribe{}]},
|
||||
StateData) ->
|
||||
#state{room = Room, host = Host, server_host = ServerHost} = StateData) ->
|
||||
BareJID = jid:remove_resource(From),
|
||||
LBareJID = jid:tolower(BareJID),
|
||||
try maps:get(LBareJID, StateData#state.subscribers) of
|
||||
@ -4067,6 +4069,7 @@ process_iq_mucsub(From, #iq{type = set, sub_els = [#muc_unsubscribe{}]},
|
||||
subscriber_nicks = Nicks},
|
||||
store_room(NewStateData, [{del_subscription, LBareJID}]),
|
||||
send_subscriptions_change_notifications(BareJID, Nick, unsubscribe, StateData),
|
||||
ejabberd_hooks:run(muc_unsubscribed, ServerHost, [ServerHost, Room, Host, BareJID]),
|
||||
NewStateData2 = case close_room_if_temporary_and_empty(NewStateData) of
|
||||
{stop, normal, _} -> stop;
|
||||
{next_state, normal_state, SD} -> SD
|
||||
|
Loading…
Reference in New Issue
Block a user