This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Commit 37eaf9c 1 parent 31b1905 commit 37eaf9c Copy full SHA for 37eaf9c
File tree 5 files changed +8
-14
lines changed
5 files changed +8
-14
lines changed Original file line number Diff line number Diff line change
1
+ Add type hints to push module.
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ class PusherConfig:
40
40
ts = attr .ib (type = int )
41
41
lang = attr .ib (type = Optional [str ])
42
42
data = attr .ib (type = Optional [JsonDict ])
43
- last_stream_ordering = attr .ib (type = Optional [ int ] )
43
+ last_stream_ordering = attr .ib (type = int )
44
44
last_success = attr .ib (type = Optional [int ])
45
45
failing_since = attr .ib (type = Optional [int ])
46
46
Original file line number Diff line number Diff line change @@ -157,7 +157,6 @@ async def _unsafe_process(self) -> None:
157
157
being run.
158
158
"""
159
159
start = 0 if INCLUDE_ALL_UNREAD_NOTIFS else self .last_stream_ordering
160
- assert start is not None
161
160
unprocessed = await self .store .get_unread_push_actions_for_user_in_range_for_email (
162
161
self .user_id , start , self .max_stream_ordering
163
162
)
@@ -220,12 +219,8 @@ async def _unsafe_process(self) -> None:
220
219
)
221
220
222
221
async def save_last_stream_ordering_and_success (
223
- self , last_stream_ordering : Optional [ int ]
222
+ self , last_stream_ordering : int
224
223
) -> None :
225
- if last_stream_ordering is None :
226
- # This happens if we haven't yet processed anything
227
- return
228
-
229
224
self .last_stream_ordering = last_stream_ordering
230
225
pusher_still_exists = await self .store .update_pusher_last_stream_ordering_and_success (
231
226
self .app_id ,
Original file line number Diff line number Diff line change @@ -176,7 +176,6 @@ async def _unsafe_process(self) -> None:
176
176
Never call this directly: use _process which will only allow this to
177
177
run once per pusher.
178
178
"""
179
- assert self .last_stream_ordering is not None
180
179
unprocessed = await self .store .get_unread_push_actions_for_user_in_range_for_http (
181
180
self .user_id , self .last_stream_ordering , self .max_stream_ordering
182
181
)
@@ -205,7 +204,6 @@ async def _unsafe_process(self) -> None:
205
204
http_push_processed_counter .inc ()
206
205
self .backoff_delay = HttpPusher .INITIAL_BACKOFF_SEC
207
206
self .last_stream_ordering = push_action ["stream_ordering" ]
208
- assert self .last_stream_ordering is not None
209
207
pusher_still_exists = await self .store .update_pusher_last_stream_ordering_and_success (
210
208
self .app_id ,
211
209
self .pushkey ,
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ async def add_pusher(
106
106
107
107
time_now_msec = self .clock .time_msec ()
108
108
109
+ # create the pusher setting last_stream_ordering to the current maximum
110
+ # stream ordering, so it will process pushes from this point onwards.
111
+ last_stream_ordering = self .store .get_room_max_stream_ordering ()
112
+
109
113
# we try to create the pusher just to validate the config: it
110
114
# will then get pulled out of the database,
111
115
# recreated, added and started: this means we have only one
@@ -124,16 +128,12 @@ async def add_pusher(
124
128
ts = time_now_msec ,
125
129
lang = lang ,
126
130
data = data ,
127
- last_stream_ordering = None ,
131
+ last_stream_ordering = last_stream_ordering ,
128
132
last_success = None ,
129
133
failing_since = None ,
130
134
)
131
135
)
132
136
133
- # create the pusher setting last_stream_ordering to the current maximum
134
- # stream ordering, so it will process pushes from this point onwards.
135
- last_stream_ordering = self .store .get_room_max_stream_ordering ()
136
-
137
137
await self .store .add_pusher (
138
138
user_id = user_id ,
139
139
access_token = access_token ,
You can’t perform that action at this time.
0 commit comments