From f2093644a6307ff23ec19d841c1c2998cc693c0c Mon Sep 17 00:00:00 2001 From: JimMoen Date: Wed, 12 Jun 2024 17:31:03 +0800 Subject: [PATCH 1/2] chore: bump gitignore --- .gitignore | 11 +++++++++++ gitignore_template | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/.gitignore b/.gitignore index 8752ee89..f8821f16 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,14 @@ test/ct.cover.spec /.idea/ rebar3.crashdump rebar3 +erlang_ls.config +# VSCode files +.vs/ +.vscode/ +# Emacs Backup files +*~ +# Emacs temporary files +.#* +*# +# For direnv +.envrc diff --git a/gitignore_template b/gitignore_template index 8752ee89..f8821f16 100644 --- a/gitignore_template +++ b/gitignore_template @@ -20,3 +20,14 @@ test/ct.cover.spec /.idea/ rebar3.crashdump rebar3 +erlang_ls.config +# VSCode files +.vs/ +.vscode/ +# Emacs Backup files +*~ +# Emacs temporary files +.#* +*# +# For direnv +.envrc From 4e4f98f0e680bbacc59376d58ba74a8dbcdbbd14 Mon Sep 17 00:00:00 2001 From: JimMoen Date: Wed, 12 Jun 2024 17:32:01 +0800 Subject: [PATCH 2/2] fix: puback hook with 5 arity See also https://github.com/emqx/emqx/blob/v5.7.0/apps/emqx/src/emqx_channel.erl#L779-L784 --- src/emqx_plugin_template.erl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/emqx_plugin_template.erl b/src/emqx_plugin_template.erl index 07328e4f..b91321e0 100644 --- a/src/emqx_plugin_template.erl +++ b/src/emqx_plugin_template.erl @@ -37,7 +37,7 @@ %% Message Pubsub Hooks -export([ on_message_publish/2 - , on_message_puback/4 + , on_message_puback/5 , on_message_delivered/3 , on_message_acked/3 , on_message_dropped/4 @@ -167,13 +167,12 @@ on_message_publish(Message, _Env) -> io:format("Publish ~p~n", [emqx_message:to_map(Message)]), {ok, Message}. -on_message_puback(_PacketId, #message{topic = _Topic} = Message, PubRes, _Env) -> - NewRC = case PubRes of +on_message_puback(_PacketId, #message{topic = _Topic} = Message, _PubRes, RC, _Env) -> + NewRC = case RC of %% Demo: some service do not want to expose the error code (129) to client; %% so here it remap 129 to 128 129 -> 128; - _ -> - PubRes + _ -> RC end, io:format("Puback ~p RC: ~p~n", [emqx_message:to_map(Message), NewRC]),