mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Add <stanza-id/> (XEP-0359) to archived messages
This commit is contained in:
parent
3300c8d994
commit
89b3471742
@ -144,6 +144,7 @@
|
||||
-define(NS_MAM_TMP, <<"urn:xmpp:mam:tmp">>).
|
||||
-define(NS_MAM_0, <<"urn:xmpp:mam:0">>).
|
||||
-define(NS_MAM_1, <<"urn:xmpp:mam:1">>).
|
||||
-define(NS_SID_0, <<"urn:xmpp:sid:0">>).
|
||||
-define(NS_PING, <<"urn:xmpp:ping">>).
|
||||
-define(NS_CARBONS_2, <<"urn:xmpp:carbons:2">>).
|
||||
-define(NS_CARBONS_1, <<"urn:xmpp:carbons:1">>).
|
||||
|
@ -169,7 +169,11 @@ user_receive_packet(Pkt, C2SState, JID, Peer, _To) ->
|
||||
attrs = [{<<"by">>, LServer},
|
||||
{<<"xmlns">>, ?NS_MAM_TMP},
|
||||
{<<"id">>, ID}]},
|
||||
NewEls = [Archived|NewPkt#xmlel.children],
|
||||
StanzaID = #xmlel{name = <<"stanza-id">>,
|
||||
attrs = [{<<"by">>, LServer},
|
||||
{<<"xmlns">>, ?NS_SID_0},
|
||||
{<<"id">>, ID}]},
|
||||
NewEls = [Archived, StanzaID|NewPkt#xmlel.children],
|
||||
NewPkt#xmlel{children = NewEls};
|
||||
_ ->
|
||||
NewPkt
|
||||
@ -194,9 +198,19 @@ user_send_packet(Pkt, C2SState, JID, Peer) ->
|
||||
muc_filter_message(Pkt, #state{config = Config} = MUCState,
|
||||
RoomJID, From, FromNick) ->
|
||||
if Config#config.mam ->
|
||||
NewPkt = strip_my_archived_tag(Pkt, MUCState#state.server_host),
|
||||
store_muc(MUCState, NewPkt, RoomJID, From, FromNick),
|
||||
NewPkt;
|
||||
By = jlib:jid_to_string(RoomJID),
|
||||
NewPkt = strip_my_archived_tag(Pkt, By),
|
||||
case store_muc(MUCState, NewPkt, RoomJID, From, FromNick) of
|
||||
{ok, ID} ->
|
||||
StanzaID = #xmlel{name = <<"stanza-id">>,
|
||||
attrs = [{<<"by">>, By},
|
||||
{<<"xmlns">>, ?NS_SID_0},
|
||||
{<<"id">>, ID}]},
|
||||
NewEls = [StanzaID|NewPkt#xmlel.children],
|
||||
NewPkt#xmlel{children = NewEls};
|
||||
_ ->
|
||||
NewPkt
|
||||
end;
|
||||
true ->
|
||||
Pkt
|
||||
end.
|
||||
@ -345,8 +359,8 @@ should_archive(#xmlel{}) ->
|
||||
|
||||
strip_my_archived_tag(Pkt, LServer) ->
|
||||
NewEls = lists:filter(
|
||||
fun(#xmlel{name = <<"archived">>,
|
||||
attrs = Attrs}) ->
|
||||
fun(#xmlel{name = Tag, attrs = Attrs})
|
||||
when Tag == <<"archived">>; Tag == <<"stanza-id">> ->
|
||||
case catch jlib:nameprep(
|
||||
xml:get_attr_s(
|
||||
<<"by">>, Attrs)) of
|
||||
|
Loading…
Reference in New Issue
Block a user