Skip to content

Commit

Permalink
Env gives nothing here, params is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Jan 12, 2022
1 parent 4185838 commit 662ec9c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
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

0 comments on commit 662ec9c

Please sign in to comment.