1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 09:49:18 +02:00

Preserve XMPP message IDs in Matrix rooms

This commit is contained in:
Alexey Shchepin 2025-03-24 20:00:33 +03:00
parent 30a7b0ef3b
commit cf13abdab6

View file

@ -216,7 +216,8 @@ route(#presence{from = From, to = #jid{luser = <<C, _/binary>>} = To,
end; end;
route(#message{from = From, to = #jid{luser = <<C, _/binary>>} = To, route(#message{from = From, to = #jid{luser = <<C, _/binary>>} = To,
type = groupchat, type = groupchat,
body = Body}) body = Body,
id = MsgID})
when C == $!; when C == $!;
C == $# -> C == $# ->
Host = ejabberd_config:get_myname(), Host = ejabberd_config:get_myname(),
@ -232,7 +233,8 @@ route(#message{from = From, to = #jid{luser = <<C, _/binary>>} = To,
JSON = JSON =
#{<<"content">> => #{<<"content">> =>
#{<<"body">> => Text, #{<<"body">> => Text,
<<"msgtype">> => <<"m.text">>}, <<"msgtype">> => <<"m.text">>,
<<"net.process-one.xmpp-id">> => MsgID},
<<"sender">> => UserID, <<"sender">> => UserID,
<<"type">> => ?ROOM_MESSAGE}, <<"type">> => ?ROOM_MESSAGE},
gen_statem:cast(Pid, {add_event, JSON}), gen_statem:cast(Pid, {add_event, JSON}),
@ -2700,7 +2702,7 @@ notify_event_xmpp(
notify_event_xmpp( notify_event_xmpp(
#event{type = ?ROOM_MESSAGE, sender = Sender, #event{type = ?ROOM_MESSAGE, sender = Sender,
json = #{<<"content">> := #{<<"msgtype">> := <<"m.text">>, json = #{<<"content">> := #{<<"msgtype">> := <<"m.text">>,
<<"body">> := Body}, <<"body">> := Body} = Content,
<<"origin_server_ts">> := OriginTS}}, <<"origin_server_ts">> := OriginTS}},
#data{kind = #multi{users = Users}} = Data) -> #data{kind = #multi{users = Users}} = Data) ->
case Sender of case Sender of
@ -2714,7 +2716,15 @@ notify_event_xmpp(
when JoinTS =< OriginTS -> when JoinTS =< OriginTS ->
From = jid:replace_resource(RoomJID, SenderUser), From = jid:replace_resource(RoomJID, SenderUser),
UserJID = jid:make(LUser, LServer, LResource), UserJID = jid:make(LUser, LServer, LResource),
Msg = #message{from = From, MsgID =
case Content of
#{<<"net.process-one.xmpp-id">> := MID} ->
MID;
_ ->
<<"">>
end,
Msg = #message{id = MsgID,
from = From,
to = UserJID, to = UserJID,
type = groupchat, type = groupchat,
body = [#text{data = Body}] body = [#text{data = Body}]