Skip to content

Commit

Permalink
Rename mod_mam to mod_mam_pm (mechanically)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzaszcz committed Jun 14, 2022
1 parent 96839a5 commit 3facead
Show file tree
Hide file tree
Showing 41 changed files with 216 additions and 216 deletions.
10 changes: 5 additions & 5 deletions big_tests/tests/amp_big_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ notify_deliver_to_online_user_bare_jid_test(Config) ->
end).

notify_deliver_to_online_user_recipient_privacy_test(Config) ->
case is_module_loaded(mod_mam) of
case is_module_loaded(mod_mam_pm) of
true -> {skip, "MAM does not support privacy lists"};
false -> do_notify_deliver_to_online_user_recipient_privacy_test(Config)
end.
Expand Down Expand Up @@ -398,7 +398,7 @@ is_offline_storage_working(Config) ->
Status == mam orelse Status == offline.

notify_deliver_to_offline_user_recipient_privacy_test(Config) ->
case is_module_loaded(mod_mam) of
case is_module_loaded(mod_mam_pm) of
true -> {skip, "MAM does not support privacy lists"};
false -> do_notify_deliver_to_offline_user_recipient_privacy_test(Config)
end.
Expand Down Expand Up @@ -735,14 +735,14 @@ user_has_no_incoming_offline_messages(FreshConfig, UserName) ->
FreshConfig, [{UserName, 1}],
fun(User) ->
client_receives_nothing(User),
case is_module_loaded(mod_mam) of
case is_module_loaded(mod_mam_pm) of
true -> client_has_no_mam_messages(User);
false -> ok
end
end).

user_has_incoming_offline_message(FreshConfig, UserName, MsgText) ->
true = is_module_loaded(mod_mam) orelse is_module_loaded(mod_offline),
true = is_module_loaded(mod_mam_pm) orelse is_module_loaded(mod_offline),
{ok, Client} = escalus_client:start(FreshConfig, UserName, <<"new-session">>),
escalus:send(Client, escalus_stanza:presence(<<"available">>)),
case is_module_loaded(mod_offline) of
Expand All @@ -751,7 +751,7 @@ user_has_incoming_offline_message(FreshConfig, UserName, MsgText) ->
end,
Presence = escalus:wait_for_stanza(Client),
escalus:assert(is_presence, Presence),
case is_module_loaded(mod_mam) of
case is_module_loaded(mod_mam_pm) of
true -> client_has_mam_message(Client);
false -> ok
end,
Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/gdpr_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ retrieve_mam_pm_and_muc_light_dont_interfere(Config) ->
[mam_helper:wait_for_archive_size(User, 2) || User <- [Alice, Bob]],

false = mongoose_helper:successful_rpc(gen_mod, get_module_opt,
[host_type(), mod_mam, archive_groupchats, undefined]),
[host_type(), mod_mam_pm, archive_groupchats, undefined]),

AliceDir = retrieve_all_personal_data(Alice, Config),
BobDir = retrieve_all_personal_data(Bob, Config),
Expand Down Expand Up @@ -914,7 +914,7 @@ retrieve_mam_pm_and_muc_light_interfere(Config) ->
mam_helper:wait_for_archive_size(Kate, 3),

true = mongoose_helper:successful_rpc(gen_mod, get_module_opt,
[host_type(), mod_mam, archive_groupchats, undefined]),
[host_type(), mod_mam_pm, archive_groupchats, undefined]),

AliceDir = retrieve_all_personal_data(Alice, Config),
BobDir = retrieve_all_personal_data(Bob, Config),
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,7 @@ metric_incremented_on_archive_request(ConfigIn) ->
end,
HostType = domain_helper:host_type(mim),
HostTypePrefix = domain_helper:make_metrics_prefix(HostType),
MongooseMetrics = [{[HostTypePrefix, backends, mod_mam, lookup], changed}],
MongooseMetrics = [{[HostTypePrefix, backends, mod_mam_pm, lookup], changed}],
Config = [{mongoose_metrics, MongooseMetrics} | ConfigIn],
escalus_fresh:story(Config, [{alice, 1}], F).

Expand Down
10 changes: 5 additions & 5 deletions big_tests/tests/mam_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -801,16 +801,16 @@ wait_for_room_archive_size(Server, Username, ExpectedSize) ->


archive_size(Server, Username) ->
rpc_apply(mod_mam, archive_size, [Server, Username]).
rpc_apply(mod_mam_pm, archive_size, [Server, Username]).

archive_size_with_host_type(HostType, Server, Username) ->
rpc_apply(mod_mam, archive_size_with_host_type, [HostType, Server, Username]).
rpc_apply(mod_mam_pm, archive_size_with_host_type, [HostType, Server, Username]).

room_archive_size(Server, Username) ->
rpc_apply(mod_mam_muc, archive_size, [Server, Username]).

delete_archive(Server, Username) ->
rpc_apply(mod_mam, delete_archive, [Server, Username]).
rpc_apply(mod_mam_pm, delete_archive, [Server, Username]).

delete_room_archive(Server, Username) ->
rpc_apply(mod_mam_muc, delete_archive, [Server, Username]).
Expand Down Expand Up @@ -967,7 +967,7 @@ put_msg({{MsgIdOwner, MsgIdRemote},
archive_message(Map2).

archive_message(#{} = Map) ->
ok = rpc_apply(mod_mam, archive_message_from_ct, [Map]).
ok = rpc_apply(mod_mam_pm, archive_message_from_ct, [Map]).

muc_bootstrap_archive(Config) ->
Room = ?config(room, Config),
Expand Down Expand Up @@ -1017,7 +1017,7 @@ archive_muc_msg({{MsgID, _},
packet => Packet}]).

get_archive_id(Server, User) ->
rpc_apply(mod_mam, archive_id, [Server, User]).
rpc_apply(mod_mam_pm, archive_id, [Server, User]).

get_muc_archive_id(MucHost, Room) ->
rpc_apply(mod_mam_muc, archive_id, [MucHost, Room]).
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/mam_proper_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ body() ->
packet(To, Body) ->
escalus_stanza:chat_to(jid:to_binary(To), Body).

%% Generates mod_mam:archive_message_params()
%% Generates mod_mam_pm:archive_message_params()
params() ->
?LET({MessId, ArcId, LocalJid, RemoteJid,
OriginId, Dir, Body, SenderId},
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/rest_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ make_arc_id(Client) ->
Server = escalus_client:server(Client),
Bin = escalus_client:short_jid(Client),
Jid = mongoose_helper:make_jid(User, Server, <<>>),
{Bin, Jid, mam_helper:rpc_apply(mod_mam, archive_id, [Server, User])}.
{Bin, Jid, mam_helper:rpc_apply(mod_mam_pm, archive_id, [Server, User])}.

fill_room_archive(RoomID, Users, AlreadyArchivedCount) ->
{TodayDate, _} = calendar:local_time(),
Expand Down
6 changes: 3 additions & 3 deletions src/mam/ejabberd_gen_mam_archive.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
-ignore_xref([behaviour_info/1]).

-callback archive_size(Size :: integer(), Host :: jid:server(),
ArchiveID :: mod_mam:archive_id(), ArchiveJID :: jid:jid())
ArchiveID :: mod_mam_pm:archive_id(), ArchiveJID :: jid:jid())
-> integer().

-callback archive_message(Result :: any(), Host :: jid:server(),
Params :: mod_mam:archive_message_params()) -> ok | {error, timeout}.
Params :: mod_mam_pm:archive_message_params()) -> ok | {error, timeout}.

-callback lookup_messages(Result :: any(), Host :: jid:server(),
Params :: map()) -> Result when
Result :: {ok, mod_mam:lookup_result()} | {error, 'policy-violation'}.
Result :: {ok, mod_mam_pm:lookup_result()} | {error, 'policy-violation'}.

-callback get_mam_pm_gdpr_data(mam_pm_gdpr_data(), mongooseim:host_type(), jid:jid()) -> mam_pm_gdpr_data().

Expand Down
14 changes: 7 additions & 7 deletions src/mam/ejabberd_gen_mam_prefs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

-ignore_xref([behaviour_info/1]).

-callback get_behaviour(Default :: mod_mam:archive_behaviour(),
Host :: jid:server(), ArcID :: mod_mam:archive_id(),
-callback get_behaviour(Default :: mod_mam_pm:archive_behaviour(),
Host :: jid:server(), ArcID :: mod_mam_pm:archive_id(),
LocJID :: jid:jid(), RemJID :: jid:jid()) -> any().

-callback set_prefs(Result :: any(), Host :: jid:server(),
ArcID :: mod_mam:archive_id(), ArcJID :: jid:jid(),
DefaultMode :: mod_mam:archive_behaviour(),
ArcID :: mod_mam_pm:archive_id(), ArcJID :: jid:jid(),
DefaultMode :: mod_mam_pm:archive_behaviour(),
AlwaysJIDs :: [jid:literal_jid()],
NeverJIDs :: [jid:literal_jid()]) -> any().

-callback get_prefs(mod_mam:preference(), _Host :: jid:server(),
ArcId :: mod_mam:archive_id(), ArcJID :: jid:jid())
-> mod_mam:preference().
-callback get_prefs(mod_mam_pm:preference(), _Host :: jid:server(),
ArcId :: mod_mam_pm:archive_id(), ArcJID :: jid:jid())
-> mod_mam_pm:preference().

6 changes: 3 additions & 3 deletions src/mam/mam_decoder.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
-type db_muc_gdpr_row() :: {ext_mess_id(), ExtData :: binary()}.
-type decoded_muc_gdpr_row() :: {ext_mess_id(), exml:element()}.

-spec decode_row(db_row(), env_vars()) -> mod_mam:message_row().
-spec decode_row(db_row(), env_vars()) -> mod_mam_pm:message_row().
decode_row({ExtMessID, ExtSrcJID, ExtData}, Env) ->
MessID = mongoose_rdbms:result_to_integer(ExtMessID),
SrcJID = decode_jid(ExtSrcJID, Env),
Packet = decode_packet(ExtData, Env),
#{id => MessID, jid => SrcJID, packet => Packet}.

-spec decode_muc_row(db_muc_row(), env_vars()) -> mod_mam:message_row().
-spec decode_muc_row(db_muc_row(), env_vars()) -> mod_mam_pm:message_row().
decode_muc_row({ExtMessID, Nick, ExtData}, Env = #{archive_jid := RoomJID}) ->
MessID = mongoose_rdbms:result_to_integer(ExtMessID),
SrcJID = jid:replace_resource(RoomJID, Nick),
Expand All @@ -31,7 +31,7 @@ decode_muc_gdpr_row({ExtMessID, ExtData}, Env) ->
{ExtMessID, Packet}.

-spec decode_retraction_info(env_vars(),
[{binary(), mod_mam:message_id(), binary()}],
[{binary(), mod_mam_pm:message_id(), binary()}],
mod_mam_utils:retraction_id()) ->
skip | mod_mam_utils:retraction_info().
decode_retraction_info(_Env, [], _) -> skip;
Expand Down
2 changes: 1 addition & 1 deletion src/mam/mam_encoder.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extend_lookup_params(#{start_ts := Start, end_ts := End, with_jid := WithJID,
remote_bare_jid => maybe_encode_bare_jid(WithJID, Env),
remote_resource => jid_to_non_empty_resource(WithJID)}.

-spec encode_message(mod_mam:archive_message_params(), env_vars(), list(db_mapping())) ->
-spec encode_message(mod_mam_pm:archive_message_params(), env_vars(), list(db_mapping())) ->
[encoded_field_value()].
encode_message(Params, Env, Mappings) ->
[encode_value_using_mapping(Params, Env, Mapping) || Mapping <- Mappings].
Expand Down
10 changes: 5 additions & 5 deletions src/mam/mam_iq.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
| 'mam_get_message_form'.

-type lookup_params() :: #{
archive_id => mod_mam:archive_id(),
archive_id => mod_mam_pm:archive_id(),
owner_jid => jid:jid(),
caller_jid => jid:jid(),
rsm => jlib:rsm_in() | undefined,
Expand All @@ -47,16 +47,16 @@
page_size => non_neg_integer(),
ordering_direction => backward | forward,
%% unix_timestamp() is in microseconds
now => mod_mam:unix_timestamp(),
now => mod_mam_pm:unix_timestamp(),
%% Filtering by date
start_ts => mod_mam:unix_timestamp() | undefined,
end_ts => mod_mam:unix_timestamp() | undefined,
start_ts => mod_mam_pm:unix_timestamp() | undefined,
end_ts => mod_mam_pm:unix_timestamp() | undefined,
%% Filtering by contact
with_jid => jid:jid() | undefined,
%% Filtering by body text
search_text => binary() | undefined,
%% Filtering Result Set based on message ids
borders => mod_mam:borders() | undefined,
borders => mod_mam_pm:borders() | undefined,
%% Affects 'policy-violation' for a case when:
%% - user does not use forms to query archive
%% - user does not provide "set" element
Expand Down
8 changes: 4 additions & 4 deletions src/mam/mam_lookup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-type filter() :: mam_filter:filter().
-type env_vars() :: mod_mam_rdbms_arch:env_vars().
-type params() :: map().
-type message_id() :: mod_mam:message_id().
-type message_id() :: mod_mam_pm:message_id().
-type maybe_rsm() :: #rsm_in{} | undefined.
-type opt_count_type() :: last_page | by_offset | none.

Expand All @@ -18,7 +18,7 @@
%% - lookup_fn
%% - decode_row_fn
-spec lookup(env_vars(), filter(), params()) ->
{ok, mod_mam:lookup_result()} | {error, item_not_found}.
{ok, mod_mam_pm:lookup_result()} | {error, item_not_found}.
lookup(Env = #{}, Filter, Params = #{rsm := RSM}) when is_list(Filter) ->
OptParams = Params#{opt_count_type => opt_count_type(RSM)},
choose_lookup_messages_strategy(Env, Filter, OptParams).
Expand Down Expand Up @@ -155,12 +155,12 @@ rsm_to_regular_lookup_vars(RSM, Filter, Offset, PageSize) ->
decode_rows(MessageRows, Env) ->
[decode_row(Row, Env) || Row <- MessageRows].

-spec decoded_row_to_message_id(mod_mam:message_row()) -> mod_mam:message_id().
-spec decoded_row_to_message_id(mod_mam_pm:message_row()) -> mod_mam_pm:message_id().
decoded_row_to_message_id(#{id := MessId}) -> MessId.

-spec extract_messages(Env :: env_vars(),
Filter :: filter(), Offset :: non_neg_integer(), Max :: pos_integer(),
Order :: asc | desc) -> [mod_mam:message_row()].
Order :: asc | desc) -> [mod_mam_pm:message_row()].
extract_messages(_Env, _Filter, _Offset, 0 = _Max, _Order) ->
[];
extract_messages(Env, Filter, Offset, Max, Order) ->
Expand Down
4 changes: 2 additions & 2 deletions src/mam/mam_send_message.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
-ignore_xref([behaviour_info/1]).

-callback send_message(
Row :: mod_mam:message_row(),
Row :: mod_mam_pm:message_row(),
ArcJID :: jid:jid(),
From :: jid:jid(),
Packet :: exml:element()) -> Acc :: mongoose_acc:t().

-spec call_send_message(
SendModule :: module(),
Row :: mod_mam:message_row(),
Row :: mod_mam_pm:message_row(),
ArcJID :: jid:jid(),
From :: jid:jid(),
Packet :: exml:element()) -> Acc :: mongoose_acc:t().
Expand Down
8 changes: 4 additions & 4 deletions src/mam/mod_mam_cache_user.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ muc_hooks(HostType) ->
%% API
%%====================================================================
-spec cached_archive_id(undefined, mongooseim:host_type(), jid:jid()) ->
mod_mam:archive_id().
mod_mam_pm:archive_id().
cached_archive_id(undefined, HostType, ArcJid) ->
case mongoose_user_cache:get_entry(HostType, ?MODULE, ArcJid) of
#{id := ArchId} -> ArchId;
Expand All @@ -84,8 +84,8 @@ cached_archive_id(undefined, HostType, ArcJid) ->
undefined
end.

-spec store_archive_id(mod_mam:archive_id(), mongooseim:host_type(), jid:jid())
-> mod_mam:archive_id().
-spec store_archive_id(mod_mam_pm:archive_id(), mongooseim:host_type(), jid:jid())
-> mod_mam_pm:archive_id().
store_archive_id(ArchId, HostType, ArcJid) ->
case erase(mam_not_cached_flag) of
undefined ->
Expand All @@ -96,7 +96,7 @@ store_archive_id(ArchId, HostType, ArcJid) ->
end.

-spec remove_archive(Acc :: map(), HostType :: mongooseim:host_type(),
ArchId :: mod_mam:archive_id(), ArcJid :: jid:jid()) -> map().
ArchId :: mod_mam_pm:archive_id(), ArcJid :: jid:jid()) -> map().
remove_archive(Acc, HostType, _UserID, ArcJid) ->
mongoose_user_cache:delete_user(HostType, ?MODULE, ArcJid),
Acc.
Expand Down
4 changes: 2 additions & 2 deletions src/mam/mod_mam_cassandra_arch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ stop(HostType) ->
ejabberd_hooks:delete(hooks(HostType)).

%% ----------------------------------------------------------------------
%% Add hooks for mod_mam
%% Add hooks for mod_mam_pm

-spec hooks(host_type()) -> [ejabberd_hooks:hook()].
hooks(HostType) ->
Expand Down Expand Up @@ -210,7 +210,7 @@ remove_archive(HostType, UserJID) ->
%% SELECT MESSAGES

-spec lookup_messages(Result :: any(), HostType :: host_type(), Params :: map()) ->
{ok, mod_mam:lookup_result()}.
{ok, mod_mam_pm:lookup_result()}.
lookup_messages({error, _Reason} = Result, _HostType, _Params) ->
Result;
lookup_messages(_Result, _HostType, #{search_text := <<_/binary>>}) ->
Expand Down
18 changes: 9 additions & 9 deletions src/mam/mod_mam_cassandra_prefs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ prepared_queries() ->
%% ----------------------------------------------------------------------
%% Internal functions and callbacks

-spec get_behaviour(Default :: mod_mam:archive_behaviour(),
HostType :: host_type(), ArchiveID :: mod_mam:archive_id(),
-spec get_behaviour(Default :: mod_mam_pm:archive_behaviour(),
HostType :: host_type(), ArchiveID :: mod_mam_pm:archive_id(),
LocJID :: jid:jid(), RemJID :: jid:jid()) -> any().
get_behaviour(DefaultBehaviour, HostType, _UserID, LocJID, RemJID) ->
BUserJID = mod_mam_utils:bare_jid(LocJID),
Expand All @@ -105,8 +105,8 @@ get_behaviour(DefaultBehaviour, HostType, _UserID, LocJID, RemJID) ->


-spec set_prefs(Result :: any(), HostType :: host_type(),
ArchiveID :: mod_mam:archive_id(), ArchiveJID :: jid:jid(),
DefaultMode :: mod_mam:archive_behaviour(),
ArchiveID :: mod_mam_pm:archive_id(), ArchiveJID :: jid:jid(),
DefaultMode :: mod_mam_pm:archive_behaviour(),
AlwaysJIDs :: [jid:literal_jid()],
NeverJIDs :: [jid:literal_jid()]) -> any().
set_prefs(_Result, HostType, _UserID, UserJID, DefaultMode, AlwaysJIDs, NeverJIDs) ->
Expand Down Expand Up @@ -144,9 +144,9 @@ encode_row(BUserJID, BRemoteJID, Behaviour, Timestamp) ->
behaviour => Behaviour, '[timestamp]' => Timestamp}.


-spec get_prefs(mod_mam:preference(), _HostType :: host_type(),
ArchiveID :: mod_mam:archive_id(), ArchiveJID :: jid:jid())
-> mod_mam:preference().
-spec get_prefs(mod_mam_pm:preference(), _HostType :: host_type(),
ArchiveID :: mod_mam_pm:archive_id(), ArchiveJID :: jid:jid())
-> mod_mam_pm:preference().
get_prefs({GlobalDefaultMode, _, _}, HostType, _UserID, UserJID) ->
BUserJID = mod_mam_utils:bare_jid(UserJID),
Params = #{user_jid => BUserJID},
Expand All @@ -155,7 +155,7 @@ get_prefs({GlobalDefaultMode, _, _}, HostType, _UserID, UserJID) ->
decode_prefs_rows(Rows, GlobalDefaultMode, [], []).


-spec remove_archive(mongoose_acc:t(), host_type(), mod_mam:archive_id(), jid:jid()) ->
-spec remove_archive(mongoose_acc:t(), host_type(), mod_mam_pm:archive_id(), jid:jid()) ->
mongoose_acc:t().
remove_archive(Acc, HostType, _UserID, UserJID) ->
remove_archive(HostType, UserJID),
Expand Down Expand Up @@ -197,7 +197,7 @@ decode_behaviour(<<"N">>) -> never.

-spec decode_prefs_rows([[term()]], DefaultMode, AlwaysJIDs, NeverJIDs) ->
{DefaultMode, AlwaysJIDs, NeverJIDs} when
DefaultMode :: mod_mam:archive_behaviour(),
DefaultMode :: mod_mam_pm:archive_behaviour(),
AlwaysJIDs :: [jid:literal_jid()],
NeverJIDs :: [jid:literal_jid()].
decode_prefs_rows([], DefaultMode, AlwaysJIDs, NeverJIDs) ->
Expand Down
Loading

0 comments on commit 3facead

Please sign in to comment.