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

Don't store mucsub presence events in offline storage

This is expanded version of pull request #3959
This commit is contained in:
Paweł Chmielowski 2022-12-21 11:12:08 +01:00
parent bc063b8f97
commit 32ace140df
2 changed files with 16 additions and 9 deletions

View File

@ -43,7 +43,7 @@
get_my_ipv4_address/0, get_my_ipv6_address/0, parse_ip_mask/1,
crypto_hmac/3, crypto_hmac/4, uri_parse/1, uri_parse/2,
match_ip_mask/3, format_hosts_list/1, format_cycle/1, delete_dir/1,
semver_to_xxyy/1, logical_processors/0]).
semver_to_xxyy/1, logical_processors/0, get_mucsub_event_type/1]).
%% Deprecated functions
-export([decode_base64/1, encode_base64/1]).
@ -168,7 +168,11 @@ unwrap_mucsub_message(_Packet) ->
false.
-spec is_mucsub_message(xmpp_element()) -> boolean().
is_mucsub_message(#message{} = OuterMsg) ->
is_mucsub_message(Packet) ->
get_mucsub_event_type(Packet) /= false.
-spec get_mucsub_event_type(xmpp_element()) -> binary() | false.
get_mucsub_event_type(#message{} = OuterMsg) ->
case xmpp:get_subtag(OuterMsg, #ps_event{}) of
#ps_event{
items = #ps_items{
@ -180,11 +184,11 @@ is_mucsub_message(#message{} = OuterMsg) ->
Node == ?NS_MUCSUB_NODES_PARTICIPANTS;
Node == ?NS_MUCSUB_NODES_PRESENCE;
Node == ?NS_MUCSUB_NODES_SUBSCRIBERS ->
true;
Node;
_ ->
false
end;
is_mucsub_message(_Packet) ->
get_mucsub_event_type(_Packet) ->
false.
-spec is_standalone_chat_state(stanza()) -> boolean().

View File

@ -473,14 +473,17 @@ need_to_store(LServer, #message{type = Type} = Packet) ->
_ ->
true
end,
case {Store, mod_offline_opt:store_empty_body(LServer)} of
{false, _} ->
case {misc:get_mucsub_event_type(Packet), Store,
mod_offline_opt:store_empty_body(LServer)} of
{?NS_MUCSUB_NODES_PRESENCE, _, _} ->
false;
{_, true} ->
{_, false, _} ->
false;
{_, _, true} ->
true;
{_, false} ->
{_, _, false} ->
Packet#message.body /= [];
{_, unless_chat_state} ->
{_, _, _, unless_chat_state} ->
not misc:is_standalone_chat_state(Packet)
end
end