mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Don't store messages with <no-store/> hint
Honor the <no-store/> hint defined in XEP-0334.
This commit is contained in:
parent
9b16d09261
commit
03fd88e4ec
@ -42,6 +42,7 @@
|
||||
-define(NS_IQDATA, <<"jabber:iq:data">>).
|
||||
-define(NS_DELAY91, <<"jabber:x:delay">>).
|
||||
-define(NS_DELAY, <<"urn:xmpp:delay">>).
|
||||
-define(NS_HINTS, <<"urn:xmpp:hints">>).
|
||||
-define(NS_EXPIRE, <<"jabber:x:expire">>).
|
||||
-define(NS_EVENT, <<"jabber:x:event">>).
|
||||
-define(NS_CHATSTATES,
|
||||
|
@ -237,22 +237,39 @@ store_packet(From, To, Packet) ->
|
||||
Type = xml:get_tag_attr_s(<<"type">>, Packet),
|
||||
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
|
||||
and (Type /= <<"headline">>) ->
|
||||
case check_event(From, To, Packet) of
|
||||
true ->
|
||||
#jid{luser = LUser, lserver = LServer} = To,
|
||||
TimeStamp = now(),
|
||||
#xmlel{children = Els} = Packet,
|
||||
Expire = find_x_expire(TimeStamp, Els),
|
||||
gen_mod:get_module_proc(To#jid.lserver, ?PROCNAME) !
|
||||
#offline_msg{us = {LUser, LServer},
|
||||
timestamp = TimeStamp, expire = Expire,
|
||||
from = From, to = To, packet = Packet},
|
||||
stop;
|
||||
case has_no_storage_hint(Packet) of
|
||||
false ->
|
||||
case check_event(From, To, Packet) of
|
||||
true ->
|
||||
#jid{luser = LUser, lserver = LServer} = To,
|
||||
TimeStamp = now(),
|
||||
#xmlel{children = Els} = Packet,
|
||||
Expire = find_x_expire(TimeStamp, Els),
|
||||
gen_mod:get_module_proc(To#jid.lserver, ?PROCNAME) !
|
||||
#offline_msg{us = {LUser, LServer},
|
||||
timestamp = TimeStamp, expire = Expire,
|
||||
from = From, to = To, packet = Packet},
|
||||
stop;
|
||||
_ -> ok
|
||||
end;
|
||||
_ -> ok
|
||||
end;
|
||||
true -> ok
|
||||
end.
|
||||
|
||||
has_no_storage_hint(Packet) ->
|
||||
case xml:get_subtag(Packet, <<"no-store">>) of
|
||||
#xmlel{attrs = Attrs} ->
|
||||
case xml:get_attr_s(<<"xmlns">>, Attrs) of
|
||||
?NS_HINTS ->
|
||||
true;
|
||||
_ ->
|
||||
false
|
||||
end;
|
||||
_ ->
|
||||
false
|
||||
end.
|
||||
|
||||
%% Check if the packet has any content about XEP-0022 or XEP-0085
|
||||
check_event(From, To, Packet) ->
|
||||
#xmlel{name = Name, attrs = Attrs, children = Els} =
|
||||
|
Loading…
Reference in New Issue
Block a user