From dab2b42f3305ed1d11ffd6fc6bd78720912c3128 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Wed, 20 Dec 2023 12:24:28 +0100 Subject: [PATCH] Handle sm features request in MAM for local archives --- big_tests/tests/mam_SUITE.erl | 12 +++++++++++- src/mam/mod_mam_pm.erl | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/big_tests/tests/mam_SUITE.erl b/big_tests/tests/mam_SUITE.erl index cea723c11a..fbbcc76440 100644 --- a/big_tests/tests/mam_SUITE.erl +++ b/big_tests/tests/mam_SUITE.erl @@ -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, @@ -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]}]} @@ -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, @@ -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), diff --git a/src/mam/mod_mam_pm.erl b/src/mam/mod_mam_pm.erl index 54b9189206..bd9b174d4c 100644 --- a/src/mam/mod_mam_pm.erl +++ b/src/mam/mod_mam_pm.erl @@ -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, @@ -165,6 +166,13 @@ disco_local_features(Acc = #{host_type := HostType, node := <<>>}, _, _) -> 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}. + %% @doc Handle an outgoing message. %% %% Note: for outgoing messages, the server MUST use the value of the 'to' @@ -667,6 +675,7 @@ is_archivable_message(HostType, Dir, Packet) -> 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},