25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

mod_mam: Always strip stanza IDs

XEP-0359 v0.5.0 says: "Stanza ID generating entities, which encounter a
<stanza-id/> element where the 'by' attribute matches the 'by' attribute
they would otherwise set, MUST delete that element even if they are not
adding their own stanza ID."
This commit is contained in:
Holger Weiss 2017-11-09 01:10:24 +01:00
parent 9c174e30b2
commit 28661d20bd

View File

@ -265,9 +265,9 @@ set_room_option(Acc, _Property, _Lang) ->
sm_receive_packet(#message{from = Peer, to = JID} = Pkt) -> sm_receive_packet(#message{from = Peer, to = JID} = Pkt) ->
LUser = JID#jid.luser, LUser = JID#jid.luser,
LServer = JID#jid.lserver, LServer = JID#jid.lserver,
case should_archive(Pkt, LServer) of
true ->
Pkt1 = strip_my_archived_tag(Pkt, LServer), Pkt1 = strip_my_archived_tag(Pkt, LServer),
case should_archive(Pkt1, LServer) of
true ->
case store_msg(Pkt1, LUser, LServer, Peer, recv) of case store_msg(Pkt1, LUser, LServer, Peer, recv) of
{ok, ID} -> {ok, ID} ->
set_stanza_id(Pkt1, JID, ID); set_stanza_id(Pkt1, JID, ID);
@ -275,7 +275,7 @@ sm_receive_packet(#message{from = Peer, to = JID} = Pkt) ->
Pkt1 Pkt1
end; end;
_ -> _ ->
Pkt Pkt1
end; end;
sm_receive_packet(Acc) -> sm_receive_packet(Acc) ->
Acc. Acc.
@ -285,9 +285,9 @@ sm_receive_packet(Acc) ->
user_send_packet({#message{to = Peer} = Pkt, #{jid := JID} = C2SState}) -> user_send_packet({#message{to = Peer} = Pkt, #{jid := JID} = C2SState}) ->
LUser = JID#jid.luser, LUser = JID#jid.luser,
LServer = JID#jid.lserver, LServer = JID#jid.lserver,
Pkt2 = case should_archive(Pkt, LServer) of
true ->
Pkt1 = strip_my_archived_tag(Pkt, LServer), Pkt1 = strip_my_archived_tag(Pkt, LServer),
Pkt2 = case should_archive(Pkt1, LServer) of
true ->
case store_msg(xmpp:set_from_to(Pkt1, JID, Peer), case store_msg(xmpp:set_from_to(Pkt1, JID, Peer),
LUser, LServer, Peer, send) of LUser, LServer, Peer, send) of
{ok, ID} -> {ok, ID} ->
@ -296,7 +296,7 @@ user_send_packet({#message{to = Peer} = Pkt, #{jid := JID} = C2SState}) ->
Pkt1 Pkt1
end; end;
false -> false ->
Pkt Pkt1
end, end,
{Pkt2, C2SState}; {Pkt2, C2SState};
user_send_packet(Acc) -> user_send_packet(Acc) ->
@ -315,9 +315,9 @@ user_send_packet_strip_tag(Acc) ->
muc_filter_message(#message{from = From} = Pkt, muc_filter_message(#message{from = From} = Pkt,
#state{config = Config, jid = RoomJID} = MUCState, #state{config = Config, jid = RoomJID} = MUCState,
FromNick) -> FromNick) ->
if Config#config.mam ->
LServer = RoomJID#jid.lserver, LServer = RoomJID#jid.lserver,
NewPkt = strip_my_archived_tag(Pkt, LServer), NewPkt = strip_my_archived_tag(Pkt, LServer),
if Config#config.mam ->
StorePkt = strip_x_jid_tags(NewPkt), StorePkt = strip_x_jid_tags(NewPkt),
case store_muc(MUCState, StorePkt, RoomJID, From, FromNick) of case store_muc(MUCState, StorePkt, RoomJID, From, FromNick) of
{ok, ID} -> {ok, ID} ->
@ -326,7 +326,7 @@ muc_filter_message(#message{from = From} = Pkt,
NewPkt NewPkt
end; end;
true -> true ->
Pkt NewPkt
end; end;
muc_filter_message(Acc, _MUCState, _FromNick) -> muc_filter_message(Acc, _MUCState, _FromNick) ->
Acc. Acc.