mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Merge pull request #207 from weiss/xep-0334
Honor XEP-0334: Message Processing Hints
This commit is contained in:
commit
5d855f3723
@ -42,6 +42,7 @@
|
|||||||
-define(NS_IQDATA, <<"jabber:iq:data">>).
|
-define(NS_IQDATA, <<"jabber:iq:data">>).
|
||||||
-define(NS_DELAY91, <<"jabber:x:delay">>).
|
-define(NS_DELAY91, <<"jabber:x:delay">>).
|
||||||
-define(NS_DELAY, <<"urn:xmpp:delay">>).
|
-define(NS_DELAY, <<"urn:xmpp:delay">>).
|
||||||
|
-define(NS_HINTS, <<"urn:xmpp:hints">>).
|
||||||
-define(NS_EXPIRE, <<"jabber:x:expire">>).
|
-define(NS_EXPIRE, <<"jabber:x:expire">>).
|
||||||
-define(NS_EVENT, <<"jabber:x:event">>).
|
-define(NS_EVENT, <<"jabber:x:event">>).
|
||||||
-define(NS_CHATSTATES,
|
-define(NS_CHATSTATES,
|
||||||
|
@ -142,11 +142,13 @@ check_and_forward(JID, To, #xmlel{name = <<"message">>, attrs = Attrs} = Packet,
|
|||||||
case xml:get_attr_s(<<"type">>, Attrs) of
|
case xml:get_attr_s(<<"type">>, Attrs) of
|
||||||
<<"chat">> ->
|
<<"chat">> ->
|
||||||
case xml:get_subtag(Packet, <<"private">>) of
|
case xml:get_subtag(Packet, <<"private">>) of
|
||||||
|
false ->
|
||||||
|
case xml:get_subtag(Packet, <<"no-copy">>) of
|
||||||
false ->
|
false ->
|
||||||
case xml:get_subtag(Packet,<<"received">>) of
|
case xml:get_subtag(Packet,<<"received">>) of
|
||||||
false ->
|
false ->
|
||||||
%% We must check if a packet contains "<sent><forwarded></sent></forwarded>" tags in order to avoid
|
%% We must check if a packet contains "<sent><forwarded></sent></forwarded>"
|
||||||
%% receiving message back to original sender.
|
%% tags in order to avoid receiving message back to original sender.
|
||||||
SubTag = xml:get_subtag(Packet,<<"sent">>),
|
SubTag = xml:get_subtag(Packet,<<"sent">>),
|
||||||
if SubTag == false ->
|
if SubTag == false ->
|
||||||
send_copies(JID, To, Packet, Direction);
|
send_copies(JID, To, Packet, Direction);
|
||||||
@ -168,6 +170,9 @@ check_and_forward(JID, To, #xmlel{name = <<"message">>, attrs = Attrs} = Packet,
|
|||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
|
|
||||||
check_and_forward(_JID, _To, _Packet, _)-> ok.
|
check_and_forward(_JID, _To, _Packet, _)-> ok.
|
||||||
|
|
||||||
|
@ -233,6 +233,10 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
|||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
add_to_log2(text, {Nick, Packet}, Room, Opts, State) ->
|
add_to_log2(text, {Nick, Packet}, Room, Opts, State) ->
|
||||||
|
case {xml:get_subtag(Packet, <<"no-store">>),
|
||||||
|
xml:get_subtag(Packet, <<"no-permanent-store">>)}
|
||||||
|
of
|
||||||
|
{false, false} ->
|
||||||
case {xml:get_subtag(Packet, <<"subject">>),
|
case {xml:get_subtag(Packet, <<"subject">>),
|
||||||
xml:get_subtag(Packet, <<"body">>)}
|
xml:get_subtag(Packet, <<"body">>)}
|
||||||
of
|
of
|
||||||
@ -244,6 +248,8 @@ add_to_log2(text, {Nick, Packet}, Room, Opts, State) ->
|
|||||||
Message = {subject, xml:get_tag_cdata(SubEl)},
|
Message = {subject, xml:get_tag_cdata(SubEl)},
|
||||||
add_message_to_log(Nick, Message, Room, Opts, State)
|
add_message_to_log(Nick, Message, Room, Opts, State)
|
||||||
end;
|
end;
|
||||||
|
{_, _} -> ok
|
||||||
|
end;
|
||||||
add_to_log2(roomconfig_change, _Occupants, Room, Opts,
|
add_to_log2(roomconfig_change, _Occupants, Room, Opts,
|
||||||
State) ->
|
State) ->
|
||||||
add_message_to_log(<<"">>, roomconfig_change, Room,
|
add_message_to_log(<<"">>, roomconfig_change, Room,
|
||||||
|
@ -237,6 +237,8 @@ store_packet(From, To, Packet) ->
|
|||||||
Type = xml:get_tag_attr_s(<<"type">>, Packet),
|
Type = xml:get_tag_attr_s(<<"type">>, Packet),
|
||||||
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
|
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
|
||||||
and (Type /= <<"headline">>) ->
|
and (Type /= <<"headline">>) ->
|
||||||
|
case has_no_storage_hint(Packet) of
|
||||||
|
false ->
|
||||||
case check_event(From, To, Packet) of
|
case check_event(From, To, Packet) of
|
||||||
true ->
|
true ->
|
||||||
#jid{luser = LUser, lserver = LServer} = To,
|
#jid{luser = LUser, lserver = LServer} = To,
|
||||||
@ -250,9 +252,24 @@ store_packet(From, To, Packet) ->
|
|||||||
stop;
|
stop;
|
||||||
_ -> ok
|
_ -> ok
|
||||||
end;
|
end;
|
||||||
|
_ -> ok
|
||||||
|
end;
|
||||||
true -> ok
|
true -> ok
|
||||||
end.
|
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 if the packet has any content about XEP-0022 or XEP-0085
|
||||||
check_event(From, To, Packet) ->
|
check_event(From, To, Packet) ->
|
||||||
#xmlel{name = Name, attrs = Attrs, children = Els} =
|
#xmlel{name = Name, attrs = Attrs, children = Els} =
|
||||||
|
Loading…
Reference in New Issue
Block a user