25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Only delete offline msgs when user has MAM enabled (#4287)

This commit is contained in:
Badlop 2024-11-11 22:41:03 +01:00
parent a657778065
commit 6f7efebb56
2 changed files with 20 additions and 1 deletions

View File

@ -46,6 +46,7 @@
mod_options/1, remove_mam_for_user_with_peer/3, remove_mam_for_user/2,
is_empty_for_user/2, is_empty_for_room/3, check_create_room/4,
process_iq/3, store_mam_message/7, make_id/0, wrap_as_mucsub/2, select/7,
is_archiving_enabled/2,
get_mam_count/2,
webadmin_menu_hostuser/4,
webadmin_page_hostuser/4,
@ -1571,6 +1572,19 @@ get_jids(undefined) ->
get_jids(Js) ->
[jid:tolower(jid:remove_resource(J)) || J <- Js].
is_archiving_enabled(LUser, LServer) ->
case gen_mod:is_loaded(LServer, mod_mam) of
true ->
case get_prefs(LUser, LServer) of
{ok, #archive_prefs{default = Default}} when Default /= never ->
true;
_ ->
false
end;
false ->
false
end.
get_commands_spec() ->
[
#ejabberd_commands{name = get_mam_count, tags = [mam],

View File

@ -306,7 +306,12 @@ c2s_copy_session(State, _) ->
State.
c2s_handle_bind2_inline({#{jid := #jid{luser = LUser, lserver = LServer}} = State, Els, Results}) ->
delete_all_msgs(LUser, LServer),
case mod_mam:is_archiving_enabled(LUser, LServer) of
true ->
delete_all_msgs(LUser, LServer);
false ->
ok
end,
{State, Els, Results}.
-spec handle_offline_query(iq()) -> iq().