25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Don't store messages with <no-store/> hint

Honor the <no-store/> hint defined in XEP-0334.
This commit is contained in:
Holger Weiss 2014-05-12 00:00:34 +02:00
parent 9b16d09261
commit 03fd88e4ec
2 changed files with 29 additions and 11 deletions

View File

@ -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,

View File

@ -237,6 +237,8 @@ store_packet(From, To, Packet) ->
Type = xml:get_tag_attr_s(<<"type">>, Packet),
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
and (Type /= <<"headline">>) ->
case has_no_storage_hint(Packet) of
false ->
case check_event(From, To, Packet) of
true ->
#jid{luser = LUser, lserver = LServer} = To,
@ -250,9 +252,24 @@ store_packet(From, To, 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} =