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

Add hooks for mqtt subscribe & unsubscribe events

This commit is contained in:
Jérôme Sautret 2023-01-05 14:58:18 +01:00
parent 92d7be4338
commit 0b1800fc10

View File

@ -147,6 +147,7 @@ subscribe({_, S, _} = USR, TopicFilter, SubOpts, ID) ->
allow -> allow ->
case check_subscribe_access(TopicFilter, USR) of case check_subscribe_access(TopicFilter, USR) of
allow -> allow ->
ejabberd_hooks:run(mqtt_subscribe, S, [USR, TopicFilter, SubOpts, ID]),
Mod:subscribe(USR, TopicFilter, SubOpts, ID); Mod:subscribe(USR, TopicFilter, SubOpts, ID);
deny -> deny ->
{error, subscribe_forbidden} {error, subscribe_forbidden}
@ -158,6 +159,7 @@ subscribe({_, S, _} = USR, TopicFilter, SubOpts, ID) ->
-spec unsubscribe(jid:ljid(), binary()) -> ok | {error, notfound | db_failure}. -spec unsubscribe(jid:ljid(), binary()) -> ok | {error, notfound | db_failure}.
unsubscribe({U, S, R}, Topic) -> unsubscribe({U, S, R}, Topic) ->
Mod = gen_mod:ram_db_mod(S, ?MODULE), Mod = gen_mod:ram_db_mod(S, ?MODULE),
ejabberd_hooks:run(mqtt_unsubscribe, S, [{U, S, R}, Topic]),
Mod:unsubscribe({U, S, R}, Topic). Mod:unsubscribe({U, S, R}, Topic).
-spec select_retained(jid:ljid(), binary(), qos(), non_neg_integer()) -> -spec select_retained(jid:ljid(), binary(), qos(), non_neg_integer()) ->