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

Env gives nothing here, params is needed #3498

Merged
merged 1 commit into from
Jan 13, 2022
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
10 changes: 5 additions & 5 deletions src/mam/mod_mam_muc_rdbms_arch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,27 @@ retract_message(HostType, #{local_jid := ArcJID} = Params) ->

-spec retract_message(mongooseim:host_type(), mod_mam:archive_message_params(), env_vars()) -> ok.
retract_message(HostType, #{archive_id := ArcID, sender_id := SenderID,
packet := Packet}, Env) ->
packet := Packet} = Params, Env) ->
case get_retract_id(Packet, Env) of
none -> ok;
RetractionId ->
Info = get_retraction_info(HostType, ArcID, SenderID, RetractionId, Env),
make_tombstone(HostType, ArcID, RetractionId, Info, Env)
make_tombstone(HostType, ArcID, RetractionId, Info, Params, Env)
end.

get_retraction_info(HostType, ArcID, SenderID, RetractionId, Env) ->
{selected, Rows} =
execute_select_messages_to_retract(HostType, ArcID, SenderID, RetractionId),
mam_decoder:decode_retraction_info(Env, Rows, RetractionId).

make_tombstone(_HostType, ArcID, RetractionId, skip, _Env) ->
make_tombstone(_HostType, ArcID, RetractionId, skip, _Params, _Env) ->
?LOG_INFO(#{what => make_tombstone_failed,
text => <<"Message to retract was not found">>,
user_id => ArcID, retraction_context => RetractionId});
make_tombstone(HostType, ArcID, _RetractionId,
RetractionInfo = #{message_id := MessID},
RetractionInfo = #{message_id := MessID}, Params,
#{archive_jid := ArcJID} = Env) ->
RetractionInfo1 = mongoose_hooks:mam_muc_retraction(HostType, RetractionInfo, Env),
RetractionInfo1 = mongoose_hooks:mam_muc_retraction(HostType, RetractionInfo, Params),
Tombstone = mod_mam_utils:tombstone(RetractionInfo1, ArcJID),
TombstoneData = mam_encoder:encode_packet(Tombstone, Env),
execute_make_tombstone(HostType, TombstoneData, ArcID, MessID).
Expand Down
10 changes: 5 additions & 5 deletions src/mam/mod_mam_rdbms_arch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@ retract_message(HostType, #{local_jid := ArcJID} = Params) ->

-spec retract_message(host_type(), mod_mam:archive_message_params(), env_vars()) -> ok.
retract_message(HostType, #{archive_id := ArcID, remote_jid := RemJID,
direction := Dir, packet := Packet}, Env) ->
direction := Dir, packet := Packet} = Params, Env) ->
case get_retract_id(Packet, Env) of
none -> ok;
RetractionId ->
Info = get_retraction_info(HostType, ArcID, RemJID, RetractionId, Dir, Env),
make_tombstone(HostType, ArcID, RetractionId, Info, Env)
make_tombstone(HostType, ArcID, RetractionId, Info, Params, Env)
end.

get_retraction_info(HostType, ArcID, RemJID, RetractionId, Dir, Env) ->
Expand All @@ -298,14 +298,14 @@ get_retraction_info(HostType, ArcID, RemJID, RetractionId, Dir, Env) ->
HostType, ArcID, ExtBareRemJID, RetractionId, ExtDir),
mam_decoder:decode_retraction_info(Env, Rows, RetractionId).

make_tombstone(_HostType, ArcID, RetractionId, skip, _Env) ->
make_tombstone(_HostType, ArcID, RetractionId, skip, _Params, _Env) ->
?LOG_INFO(#{what => make_tombstone_failed,
text => <<"Message to retract was not found">>,
user_id => ArcID, retraction_context => RetractionId});
make_tombstone(HostType, ArcID, _RetractionId,
RetractionInfo = #{message_id := MessID},
RetractionInfo = #{message_id := MessID}, Params,
#{archive_jid := ArcJID} = Env) ->
RetractionInfo1 = mongoose_hooks:mam_retraction(HostType, RetractionInfo, Env),
RetractionInfo1 = mongoose_hooks:mam_retraction(HostType, RetractionInfo, Params),
Tombstone = mod_mam_utils:tombstone(RetractionInfo1, ArcJID),
TombstoneData = mam_encoder:encode_packet(Tombstone, Env),
execute_make_tombstone(HostType, TombstoneData, ArcID, MessID).
Expand Down
6 changes: 3 additions & 3 deletions src/mongoose_hooks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ mam_archive_sync(HostType) ->
%% @doc Notifies of a message retraction
-spec mam_retraction(mongooseim:host_type(),
mod_mam_utils:retraction_info(),
mod_mam_rdbms_arch:env_vars()) ->
mod_mam:archive_message_params()) ->
mod_mam_utils:retraction_info().
mam_retraction(HostType, RetractionInfo, Env) ->
run_fold(mam_retraction, HostType, RetractionInfo, Env).
Expand Down Expand Up @@ -1176,8 +1176,8 @@ mam_muc_archive_sync(HostType) ->

%% @doc Notifies of a muc message retraction
-spec mam_muc_retraction(mongooseim:host_type(),
mod_mam_utils:retraction_info(),
mod_mam_rdbms_arch:env_vars()) ->
mod_mam_utils:retraction_info(),
mod_mam:archive_message_params()) ->
mod_mam_utils:retraction_info().
mam_muc_retraction(HostType, RetractionInfo, Env) ->
run_fold(mam_muc_retraction, HostType, RetractionInfo, Env).
Expand Down