aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2019-04-15 12:02:43 +0200
committerPaweł Chmielowski <pchmielowski@process-one.net>2019-04-15 12:03:30 +0200
commitc96a925fdedfbb6941cee64b63e6f78a52b585fd (patch)
tree505f8320a7150f989bd762859a14643bd34934cb /src
parentFeed whole image to eimp:identify/1 (diff)
Add hooks for tracking mucsub subscriptions changes
Diffstat (limited to 'src')
-rw-r--r--src/mod_muc_room.erl9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index cbc967da4..4b02e0939 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -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