Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
gustawlippa committed Sep 16, 2024
1 parent 4348f52 commit 5d0747e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,9 @@ init_per_group(nostore, Config) ->
init_per_group(sm, Config) ->
Config1 = dynamic_modules:save_modules(host_type(), Config),
DefaultSMConfig = config_parser_helper:default_mod_config(mod_stream_management),
dynamic_modules:ensure_modules(host_type(), [{mod_stream_management, DefaultSMConfig}]),
MnesiaOrCets = ct_helper:get_internal_database(),
SMConfig = DefaultSMConfig#{backend => MnesiaOrCets},
dynamic_modules:ensure_modules(host_type(), [{mod_stream_management, SMConfig}]),
Config1;
init_per_group(archived, Config) ->
Config;
Expand Down
20 changes: 18 additions & 2 deletions src/mam/mod_mam_pm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
filter_packet/3,
remove_user/3,
determine_amp_strategy/3,
sm_filter_offline_message/3]).
sm_filter_offline_message/3,
filter_unacknowledged_messages/3]).

%% ejabberd handlers
-export([process_mam_iq/5]).
Expand Down Expand Up @@ -273,6 +274,11 @@ get_personal_data(Acc, #{jid := ArcJID}, #{host_type := HostType}) ->
Entries = mongoose_hooks:get_mam_pm_gdpr_data(HostType, ArcJID),
{ok, [{mam_pm, Schema, Entries} | Acc]}.

-spec filter_unacknowledged_messages(Buffer :: [mongoose_acc:t()], Params :: map(), Extra :: map()) ->
{ok, [mongoose_acc:t()]}.
filter_unacknowledged_messages(Buffer, _, _) ->
{ok, [acc_with_perm_mam_id(Acc) || Acc <- Buffer]}.

%% ----------------------------------------------------------------------
%% Internal functions

Expand Down Expand Up @@ -531,6 +537,15 @@ return_acc_with_mam_id_if_configured(ExtMessId, HostType, Acc) ->
true -> mongoose_acc:set_permanent(mam, mam_id, ExtMessId, Acc)
end.

-spec acc_with_perm_mam_id(Acc :: mongoose_acc:t()) -> Acc :: mongoose_acc:t().
acc_with_perm_mam_id(Acc) ->
case mongoose_acc:get(mam, mam_id, undefined, Acc) of
undefined ->
Acc;

Check warning on line 544 in src/mam/mod_mam_pm.erl

View check run for this annotation

Codecov / codecov/patch

src/mam/mod_mam_pm.erl#L544

Added line #L544 was not covered by tests
MamID ->
mongoose_acc:set_permanent(mam, mam_id, MamID, Acc)
end.

is_interesting(LocJID, RemJID) ->
HostType = jid_to_host_type(LocJID),
ArcID = archive_id_int(HostType, LocJID),
Expand Down Expand Up @@ -732,7 +747,8 @@ hooks(HostType) ->
{anonymous_purge, HostType, fun ?MODULE:remove_user/3, #{}, 50},
{amp_determine_strategy, HostType, fun ?MODULE:determine_amp_strategy/3, #{}, 20},
{sm_filter_offline_message, HostType, fun ?MODULE:sm_filter_offline_message/3, #{}, 50},
{get_personal_data, HostType, fun ?MODULE:get_personal_data/3, #{}, 50}
{get_personal_data, HostType, fun ?MODULE:get_personal_data/3, #{}, 50},
{filter_unacknowledged_messages, HostType, fun ?MODULE:filter_unacknowledged_messages/3, #{}, 50}
].

add_iq_handlers(HostType, Opts) ->
Expand Down

0 comments on commit 5d0747e

Please sign in to comment.