end.
should_archive(#xmlel{name = <<"message">>} = Pkt) ->
- case {xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs),
- xml:get_subtag_cdata(Pkt, <<"body">>)} of
- {<<"error">>, _} ->
- false;
- {<<"groupchat">>, _} ->
+ case xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of
+ <<"error">> ->
false;
- {_, <<>>} ->
- %% Empty body
+ <<"groupchat">> ->
false;
_ ->
- true
+ case check_store_hint(Pkt) of
+ store ->
+ true;
+ no_store ->
+ false;
+ none ->
+ case xml:get_subtag_cdata(Pkt, <<"body">>) of
+ <<>> ->
+ %% Empty body
+ false;
+ _ ->
+ true
+ end
+ end
end;
should_archive(#xmlel{}) ->
false.
%% TODO
true.
+check_store_hint(Pkt) ->
+ case has_store_hint(Pkt) of
+ true ->
+ store;
+ false ->
+ case has_no_store_hint(Pkt) of
+ true ->
+ no_store;
+ false ->
+ none
+ end
+ end.
+
+has_store_hint(Message) ->
+ xml:get_subtag_with_xmlns(Message, <<"store">>, ?NS_HINTS)
+ /= false.
+
+has_no_store_hint(Message) ->
+ xml:get_subtag_with_xmlns(Message, <<"no-store">>, ?NS_HINTS)
+ /= false orelse
+ xml:get_subtag_with_xmlns(Message, <<"no-storage">>, ?NS_HINTS)
+ /= false orelse
+ xml:get_subtag_with_xmlns(Message, <<"no-permanent-store">>, ?NS_HINTS)
+ /= false orelse
+ xml:get_subtag_with_xmlns(Message, <<"no-permanent-storage">>, ?NS_HINTS)
+ /= false.
+
store_msg(C2SState, Pkt, LUser, LServer, Peer, Dir) ->
Prefs = get_prefs(LUser, LServer),
case should_archive_peer(C2SState, Prefs, Peer) of