-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">>).
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
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.
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