diff --git a/src/mam/mod_mam_muc_rdbms_arch.erl b/src/mam/mod_mam_muc_rdbms_arch.erl index 46d8a8b8fb..bd0f1986cd 100644 --- a/src/mam/mod_mam_muc_rdbms_arch.erl +++ b/src/mam/mod_mam_muc_rdbms_arch.erl @@ -274,7 +274,8 @@ make_tombstone(_HostType, ArcID, RetractionId, skip, _Env) -> make_tombstone(HostType, ArcID, _RetractionId, RetractionInfo = #{message_id := MessID}, #{archive_jid := ArcJID} = Env) -> - Tombstone = mod_mam_utils:tombstone(RetractionInfo, ArcJID), + RetractionInfo1 = mongoose_hooks:mam_muc_retraction(HostType, RetractionInfo, Env), + Tombstone = mod_mam_utils:tombstone(RetractionInfo1, ArcJID), TombstoneData = mam_encoder:encode_packet(Tombstone, Env), execute_make_tombstone(HostType, TombstoneData, ArcID, MessID). diff --git a/src/mam/mod_mam_rdbms_arch.erl b/src/mam/mod_mam_rdbms_arch.erl index f9c522b040..197f949440 100644 --- a/src/mam/mod_mam_rdbms_arch.erl +++ b/src/mam/mod_mam_rdbms_arch.erl @@ -305,7 +305,8 @@ make_tombstone(_HostType, ArcID, RetractionId, skip, _Env) -> make_tombstone(HostType, ArcID, _RetractionId, RetractionInfo = #{message_id := MessID}, #{archive_jid := ArcJID} = Env) -> - Tombstone = mod_mam_utils:tombstone(RetractionInfo, ArcJID), + RetractionInfo1 = mongoose_hooks:mam_retraction(HostType, RetractionInfo, Env), + Tombstone = mod_mam_utils:tombstone(RetractionInfo1, ArcJID), TombstoneData = mam_encoder:encode_packet(Tombstone, Env), execute_make_tombstone(HostType, TombstoneData, ArcID, MessID). diff --git a/src/mongoose_hooks.erl b/src/mongoose_hooks.erl index 92f9419e55..3a2406aa17 100644 --- a/src/mongoose_hooks.erl +++ b/src/mongoose_hooks.erl @@ -98,7 +98,8 @@ mam_lookup_messages/2, mam_archive_message/2, mam_flush_messages/2, - mam_archive_sync/1]). + mam_archive_sync/1, + mam_retraction/3]). -export([mam_muc_archive_id/2, mam_muc_archive_size/3, @@ -109,7 +110,8 @@ mam_muc_lookup_messages/2, mam_muc_archive_message/2, mam_muc_flush_messages/2, - mam_muc_archive_sync/1]). + mam_muc_archive_sync/1, + mam_muc_retraction/3]). -export([get_mam_pm_gdpr_data/2, get_mam_muc_gdpr_data/2, @@ -1044,6 +1046,14 @@ mam_flush_messages(HookServer, MessageCount) -> mam_archive_sync(HostType) -> run_hook_for_host_type(mam_archive_sync, HostType, ok, [HostType]). +%% @doc Notifies of a message retraction +-spec mam_retraction(mongooseim:host_type(), + mod_mam_utils:retraction_info(), + mod_mam_rdbms_arch:env_vars()) -> + mod_mam_utils:retraction_info(). +mam_retraction(HostType, RetractionInfo, Env) -> + {ok, RetractionInfo1} = gen_hook:run_fold(mam_retraction, HostType, RetractionInfo, Env), + RetractionInfo1. %% MAM MUC related hooks @@ -1165,6 +1175,15 @@ mam_muc_flush_messages(HookServer, MessageCount) -> mam_muc_archive_sync(HostType) -> run_hook_for_host_type(mam_muc_archive_sync, HostType, ok, [HostType]). +%% @doc Notifies of a muc message retraction +-spec mam_muc_retraction(mongooseim:host_type(), + mod_mam_utils:retraction_info(), + mod_mam_rdbms_arch:env_vars()) -> + mod_mam_utils:retraction_info(). +mam_muc_retraction(HostType, RetractionInfo, Env) -> + {ok, RetractionInfo1} = gen_hook:run_fold(mam_muc_retraction, HostType, RetractionInfo, Env), + RetractionInfo1. + %% GDPR related hooks %%% @doc `get_mam_pm_gdpr_data' hook is called to provide