diff options
| author | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-05-12 00:00:34 +0200 |
|---|---|---|
| committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-05-12 00:00:34 +0200 |
| commit | 03fd88e4ecdba349e42288f38bd6d6c5dacb1cf8 (patch) | |
| tree | 363dfe0abc413c5347e530bad908b801f631525f /src/mod_offline.erl | |
| parent | Don't carbon copy messages with <no-copy/> hint (diff) | |
Don't store messages with <no-store/> hint
Honor the <no-store/> hint defined in XEP-0334.
Diffstat (limited to 'src/mod_offline.erl')
| -rw-r--r-- | src/mod_offline.erl | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/mod_offline.erl b/src/mod_offline.erl index fca227d31..f27d35830 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -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} = |
