Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle SM features request in MAM for local archives #4194

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
muc_no_elements/1,
muc_only_stanzaid/1,
mam_service_discovery/1,
mam_service_discovery_to_client_bare_jid/1,
muc_service_discovery/1,
easy_archive_request/1,
easy_archive_request_for_the_receiver/1,
Expand Down Expand Up @@ -365,7 +366,7 @@ basic_groups() ->
[{mam04, [parallel], chat_markers_cases()}]},
{disabled_retraction, [],
[{mam06, [parallel], disabled_retract_cases() ++
[mam_service_discovery]}]},
[mam_service_discovery, mam_service_discovery_to_client_bare_jid]}]},
{muc_disabled_retraction, [],
[{muc06, [parallel], disabled_muc_retract_cases() ++
[muc_service_discovery]}]}
Expand All @@ -381,6 +382,7 @@ mam_metrics_cases() ->

mam_cases() ->
[mam_service_discovery,
mam_service_discovery_to_client_bare_jid,
easy_archive_request,
easy_archive_request_for_the_receiver,
message_sent_to_yourself,
Expand Down Expand Up @@ -2937,6 +2939,14 @@ mam_service_discovery(Config) ->
end,
escalus_fresh:story(Config, [{alice, 1}], F).

mam_service_discovery_to_client_bare_jid(Config) ->
_P = ?config(props, Config),
F = fun(Alice) ->
Address = inbox_helper:to_bare_lower(Alice),
discover_features(Config, Alice, Address)
end,
escalus_fresh:story(Config, [{alice, 1}], F).

%% Check, that MUC is supported.
muc_service_discovery(Config) ->
_P = ?config(props, Config),
Expand Down
9 changes: 9 additions & 0 deletions src/mam/mod_mam_pm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

%% hook handlers
-export([disco_local_features/3,
disco_sm_features/3,
user_send_message/3,
filter_packet/3,
remove_user/3,
Expand Down Expand Up @@ -165,6 +166,13 @@
disco_local_features(Acc, _, _) ->
{ok, Acc}.

-spec disco_sm_features(mongoose_disco:feature_acc(),
map(), map()) -> {ok, mongoose_disco:feature_acc()}.
disco_sm_features(Acc = #{host_type := HostType, node := <<>>}, _, _) ->
{ok, mongoose_disco:add_features(mod_mam_utils:features(?MODULE, HostType), Acc)};
disco_sm_features(Acc, _, _) ->
{ok, Acc}.

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

View check run for this annotation

Codecov / codecov/patch

src/mam/mod_mam_pm.erl#L174

Added line #L174 was not covered by tests

%% @doc Handle an outgoing message.
%%
%% Note: for outgoing messages, the server MUST use the value of the 'to'
Expand Down Expand Up @@ -667,6 +675,7 @@
hooks(HostType) ->
[
{disco_local_features, HostType, fun ?MODULE:disco_local_features/3, #{}, 99},
{disco_sm_features, HostType, fun ?MODULE:disco_sm_features/3, #{}, 99},
{user_send_message, HostType, fun ?MODULE:user_send_message/3, #{}, 60},
{filter_local_packet, HostType, fun ?MODULE:filter_packet/3, #{}, 60},
{remove_user, HostType, fun ?MODULE:remove_user/3, #{}, 50},
Expand Down