Skip to content

Commit

Permalink
Merge pull request #4194 from esl/mam-disco-sm-features
Browse files Browse the repository at this point in the history
Handle SM features request in MAM for local archives
  • Loading branch information
JanuszJakubiec authored Dec 29, 2023
2 parents 18d0bd5 + dab2b42 commit 112e3a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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 = #{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'
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 112e3a6

Please sign in to comment.