Skip to content

Commit 701672e

Browse files
committed
Do not send INVITE (for invite-notify) from backlog events
1 parent b7a13e3 commit 701672e

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

lib/matrix_client/poller.ex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,14 @@ defmodule M51.MatrixClient.Poller do
428428
end
429429

430430
"invite" ->
431-
send.(%M51.Irc.Command{
432-
tags: %{"account" => sender},
433-
source: nick2nuh(sender),
434-
command: "INVITE",
435-
params: [target, channel]
436-
})
431+
if !is_backlog do
432+
send.(%M51.Irc.Command{
433+
tags: %{"account" => sender},
434+
source: nick2nuh(sender),
435+
command: "INVITE",
436+
params: [target, channel]
437+
})
438+
end
437439

438440
_ ->
439441
send.(%M51.Irc.Command{

test/matrix_client/poller_test.exs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,34 @@ defmodule M51.MatrixClient.PollerTest do
11501150
}
11511151
})
11521152

1153-
assert_line(
1154-
":inviter:[email protected] INVITE invited:example.com :#test:example.org\r\n"
1155-
)
1153+
if !unquote(is_backlog) do
1154+
assert_line(
1155+
":inviter:[email protected] INVITE invited:example.com :#test:example.org\r\n"
1156+
)
1157+
end
1158+
1159+
timeline_events = [
1160+
%{
1161+
"content" => %{"body" => "hello world", "msgtype" => "m.text"},
1162+
"event_id" => "$event3",
1163+
"origin_server_ts" => 1_632_946_233_579,
1164+
"sender" => "@nick:example.org",
1165+
"type" => "m.room.message",
1166+
"unsigned" => %{}
1167+
}
1168+
]
1169+
1170+
M51.MatrixClient.Poller.handle_events(self(), false, %{
1171+
"rooms" => %{
1172+
"join" => %{
1173+
"!testid:example.org" => %{
1174+
"timeline" => %{"events" => timeline_events}
1175+
}
1176+
}
1177+
}
1178+
})
1179+
1180+
assert_line(":nick:[email protected] PRIVMSG #test:example.org :hello world\r\n")
11561181
end
11571182
end
11581183

0 commit comments

Comments
 (0)