Merge pull request #673 from farhadi/master

Fixing issues with unsubscribe hook
This commit is contained in:
Feng Lee 2016-09-05 08:55:50 +08:00 committed by GitHub
commit 887a3a0578
2 changed files with 4 additions and 4 deletions

View File

@ -44,9 +44,9 @@ rewrite_subscribe({_ClientId, _Username}, {Topic, Opts}, Sections) ->
lager:info("Rewrite subscribe: ~p", [{Topic, Opts}]),
{ok, {match_topic(Topic, Sections), Opts}}.
rewrite_unsubscribe({_ClientId, _Username}, {Topic, Opts}, Sections) ->
lager:info("Rewrite unsubscribe: ~p", [{Topic, Opts}]),
{ok, {match_topic(Topic, Sections), Opts}}.
rewrite_unsubscribe({_ClientId, _Username}, Topic, Sections) ->
lager:info("Rewrite unsubscribe: ~p", [Topic]),
{ok, match_topic(Topic, Sections)}.
rewrite_publish(Message=#mqtt_message{topic = Topic}, Sections) ->
%%TODO: this will not work if the client is always online.

View File

@ -336,7 +336,7 @@ handle_cast({unsubscribe, Topics}, Session = #session{client_id = ClientId,
Subscriptions1 =
lists:foldl(fun(RawTopic, SubDict) ->
{Topic0, _Opts} = emqttd_topic:strip(RawTopic),
case emqttd:run_hooks('client.unsubscribe', [ClientId, Username], Topic0) of
case emqttd:run_hooks('client.unsubscribe', [{ClientId, Username}], Topic0) of
{ok, Topic1} ->
case dict:find(Topic1, SubDict) of
{ok, _Qos} ->