Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
gustawlippa committed Sep 12, 2024
1 parent 4348f52 commit 24c3ea4
Showing 1 changed file with 18 additions and 2 deletions.
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 24c3ea4

Please sign in to comment.