mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +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_TMP, <<"urn:xmpp:mam:tmp">>).
|
||||||
-define(NS_MAM_0, <<"urn:xmpp:mam:0">>).
|
-define(NS_MAM_0, <<"urn:xmpp:mam:0">>).
|
||||||
-define(NS_MAM_1, <<"urn:xmpp:mam:1">>).
|
-define(NS_MAM_1, <<"urn:xmpp:mam:1">>).
|
||||||
|
-define(NS_SID_0, <<"urn:xmpp:sid:0">>).
|
||||||
-define(NS_PING, <<"urn:xmpp:ping">>).
|
-define(NS_PING, <<"urn:xmpp:ping">>).
|
||||||
-define(NS_CARBONS_2, <<"urn:xmpp:carbons:2">>).
|
-define(NS_CARBONS_2, <<"urn:xmpp:carbons:2">>).
|
||||||
-define(NS_CARBONS_1, <<"urn:xmpp:carbons:1">>).
|
-define(NS_CARBONS_1, <<"urn:xmpp:carbons:1">>).
|
||||||
|
@ -169,7 +169,11 @@ user_receive_packet(Pkt, C2SState, JID, Peer, _To) ->
|
|||||||
attrs = [{<<"by">>, LServer},
|
attrs = [{<<"by">>, LServer},
|
||||||
{<<"xmlns">>, ?NS_MAM_TMP},
|
{<<"xmlns">>, ?NS_MAM_TMP},
|
||||||
{<<"id">>, ID}]},
|
{<<"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#xmlel{children = NewEls};
|
||||||
_ ->
|
_ ->
|
||||||
NewPkt
|
NewPkt
|
||||||
@ -194,9 +198,19 @@ user_send_packet(Pkt, C2SState, JID, Peer) ->
|
|||||||
muc_filter_message(Pkt, #state{config = Config} = MUCState,
|
muc_filter_message(Pkt, #state{config = Config} = MUCState,
|
||||||
RoomJID, From, FromNick) ->
|
RoomJID, From, FromNick) ->
|
||||||
if Config#config.mam ->
|
if Config#config.mam ->
|
||||||
NewPkt = strip_my_archived_tag(Pkt, MUCState#state.server_host),
|
By = jlib:jid_to_string(RoomJID),
|
||||||
store_muc(MUCState, NewPkt, RoomJID, From, FromNick),
|
NewPkt = strip_my_archived_tag(Pkt, By),
|
||||||
NewPkt;
|
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 ->
|
true ->
|
||||||
Pkt
|
Pkt
|
||||||
end.
|
end.
|
||||||
@ -345,8 +359,8 @@ should_archive(#xmlel{}) ->
|
|||||||
|
|
||||||
strip_my_archived_tag(Pkt, LServer) ->
|
strip_my_archived_tag(Pkt, LServer) ->
|
||||||
NewEls = lists:filter(
|
NewEls = lists:filter(
|
||||||
fun(#xmlel{name = <<"archived">>,
|
fun(#xmlel{name = Tag, attrs = Attrs})
|
||||||
attrs = Attrs}) ->
|
when Tag == <<"archived">>; Tag == <<"stanza-id">> ->
|
||||||
case catch jlib:nameprep(
|
case catch jlib:nameprep(
|
||||||
xml:get_attr_s(
|
xml:get_attr_s(
|
||||||
<<"by">>, Attrs)) of
|
<<"by">>, Attrs)) of
|
||||||
|
Loading…
Reference in New Issue
Block a user