25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Add pubsub subscribe/unsubscribe hook

This commit is contained in:
Christophe Romain 2016-04-28 15:57:55 +02:00
parent c585f74730
commit 639c2fb640

View File

@ -2103,6 +2103,9 @@ subscribe_node(Host, Node, From, JID, Configuration) ->
Type = TNode#pubsub_node.type,
Options = TNode#pubsub_node.options,
send_items(Host, Node, Nidx, Type, Options, Subscriber, last),
ServerHost = serverhost(Host),
ejabberd_hooks:run(pubsub_subscribe_node, ServerHost,
[ServerHost, Host, Node, Subscriber, SubId]),
case Result of
default -> {result, Reply({subscribed, SubId})};
_ -> {result, Result}
@ -2149,7 +2152,11 @@ unsubscribe_node(Host, Node, From, Subscriber, SubId) ->
node_call(Host, Type, unsubscribe_node, [Nidx, From, Subscriber, SubId])
end,
case transaction(Host, Node, Action, sync_dirty) of
{result, {_, default}} -> {result, []};
{result, {_, default}} ->
ServerHost = serverhost(Host),
ejabberd_hooks:run(pubsub_unsubscribe_node, ServerHost,
[ServerHost, Host, Node, Subscriber, SubId]),
{result, []};
% {result, {_, Result}} -> {result, Result};
Error -> Error
end.