@@ -33,18 +33,17 @@ defmodule M51.MatrixClient.Poller do
3333
3434 # If we are being restarted, pick up from where the last process stopped.
3535 since = M51.MatrixClient.State . poll_since_marker ( state )
36- handled_event_ids = M51.MatrixClient.State . handled_events ( state )
3736
3837 if M51.IrcConn.State . registered ( irc_state ) do
39- loop_poll ( sup_pid , since , handled_event_ids )
38+ loop_poll ( sup_pid , since )
4039 else
4140 receive do
42- :start_polling -> loop_poll ( sup_pid , since , handled_event_ids )
41+ :start_polling -> loop_poll ( sup_pid , since )
4342 end
4443 end
4544 end
4645
47- def loop_poll ( sup_pid , since , handled_event_ids \\ MapSet . new ( ) ) do
46+ def loop_poll ( sup_pid , since ) do
4847 client = M51.IrcConn.Supervisor . matrix_client ( sup_pid )
4948 state = M51.IrcConn.Supervisor . matrix_state ( sup_pid )
5049
@@ -56,14 +55,13 @@ defmodule M51.MatrixClient.Poller do
5655 end
5756
5857 raw_client ->
59- since = poll_one ( sup_pid , since , handled_event_ids , raw_client )
58+ since = poll_one ( sup_pid , since , raw_client )
6059 M51.MatrixClient.State . update_poll_since_marker ( state , since )
61- # do not pass handled_event_ids, no longer needed
6260 loop_poll ( sup_pid , since )
6361 end
6462 end
6563
66- defp poll_one ( sup_pid , since , handled_event_ids , raw_client ) do
64+ defp poll_one ( sup_pid , since , raw_client ) do
6765 query = % {
6866 # Completely arbitrary value. Just make sure it's lower than recv_timeout below
6967 "timeout" => "600000"
@@ -79,30 +77,19 @@ defmodule M51.MatrixClient.Poller do
7977
8078 case M51.Matrix.RawClient . get ( raw_client , path , [ ] , options ) do
8179 { :ok , events } ->
82- handle_events ( sup_pid , is_backlog , events , handled_event_ids )
80+ handle_events ( sup_pid , is_backlog , events )
8381 events [ "next_batch" ]
8482
8583 { :error , code , _ } when code >= 500 and code < 600 ->
8684 # server error, try again
87- poll_one ( sup_pid , since , handled_event_ids , raw_client )
85+ poll_one ( sup_pid , since , raw_client )
8886 end
8987 end
9088
9189 @ doc """
9290 Internal method that dispatches event; public only so it can be unit-tested.
9391 """
94- def handle_events ( sup_pid , is_backlog , events , handled_event_ids \\ MapSet . new ( ) ) do
95- irc_state = M51.IrcConn.Supervisor . state ( sup_pid )
96- capabilities = M51.IrcConn.State . capabilities ( irc_state )
97- writer = M51.IrcConn.Supervisor . writer ( sup_pid )
98-
99- write = fn cmd ->
100- M51.IrcConn.Writer . write_command (
101- writer ,
102- M51.Irc.Command . downgrade ( cmd , capabilities )
103- )
104- end
105-
92+ def handle_events ( sup_pid , is_backlog , events ) do
10693 events
10794 |> Map . get ( "rooms" , % { } )
10895 |> Map . get ( "join" , % { } )
@@ -113,8 +100,6 @@ defmodule M51.MatrixClient.Poller do
113100 room_id ,
114101 :join ,
115102 is_backlog ,
116- handled_event_ids ,
117- write ,
118103 event
119104 )
120105 end )
@@ -129,8 +114,6 @@ defmodule M51.MatrixClient.Poller do
129114 room_id ,
130115 :leave ,
131116 is_backlog ,
132- handled_event_ids ,
133- write ,
134117 event
135118 )
136119 end )
@@ -145,8 +128,6 @@ defmodule M51.MatrixClient.Poller do
145128 room_id ,
146129 :invite ,
147130 is_backlog ,
148- handled_event_ids ,
149- write ,
150131 event
151132 )
152133 end )
@@ -204,7 +185,7 @@ defmodule M51.MatrixClient.Poller do
204185 handle_event ( sup_pid , room_id , sender , is_backlog , write , event )
205186 # Don't mark it handled right now, there is still some processing to
206187 # do below.
207- # M51.MatrixClient.State.mark_handled_event(state, event_id)
188+ # M51.MatrixClient.State.mark_handled_event(state, room_id, event_id)
208189 end
209190 end )
210191
@@ -244,7 +225,7 @@ defmodule M51.MatrixClient.Poller do
244225
245226 handle_event ( sup_pid , room_id , sender , is_backlog , write , event )
246227
247- M51.MatrixClient.State . mark_handled_event ( state , event_id )
228+ M51.MatrixClient.State . mark_handled_event ( state , room_id , event_id )
248229 end
249230 end )
250231 end
@@ -1121,7 +1102,7 @@ defmodule M51.MatrixClient.Poller do
11211102 nil
11221103 end
11231104
1124- M51.MatrixClient.State . mark_handled_event ( state , event_id )
1105+ M51.MatrixClient.State . mark_handled_event ( state , room_id , event_id )
11251106 end
11261107 end )
11271108 end
0 commit comments