@@ -328,7 +328,7 @@ async def _start_pusher(self, pusher_config: PusherConfig) -> Optional[Pusher]:
328
328
return None
329
329
330
330
try :
331
- p = self .pusher_factory .create_pusher (pusher_config )
331
+ pusher = self .pusher_factory .create_pusher (pusher_config )
332
332
except PusherConfigException as e :
333
333
logger .warning (
334
334
"Pusher incorrectly configured id=%i, user=%s, appid=%s, pushkey=%s: %s" ,
@@ -346,23 +346,28 @@ async def _start_pusher(self, pusher_config: PusherConfig) -> Optional[Pusher]:
346
346
)
347
347
return None
348
348
349
- if not p :
349
+ if not pusher :
350
350
return None
351
351
352
- appid_pushkey = "%s:%s" % (pusher_config .app_id , pusher_config .pushkey )
352
+ appid_pushkey = "%s:%s" % (pusher .app_id , pusher .pushkey )
353
353
354
- byuser = self .pushers .setdefault (pusher_config . user_name , {})
354
+ byuser = self .pushers .setdefault (pusher . user_id , {})
355
355
if appid_pushkey in byuser :
356
- byuser [appid_pushkey ]. on_stop ()
357
- byuser [ appid_pushkey ] = p
356
+ previous_pusher = byuser [appid_pushkey ]
357
+ previous_pusher . on_stop ()
358
358
359
- synapse_pushers .labels (type (p ).__name__ , p .app_id ).inc ()
359
+ synapse_pushers .labels (
360
+ type (previous_pusher ).__name__ , previous_pusher .app_id
361
+ ).dec ()
362
+ byuser [appid_pushkey ] = pusher
363
+
364
+ synapse_pushers .labels (type (pusher ).__name__ , pusher .app_id ).inc ()
360
365
361
366
# Check if there *may* be push to process. We do this as this check is a
362
367
# lot cheaper to do than actually fetching the exact rows we need to
363
368
# push.
364
- user_id = pusher_config . user_name
365
- last_stream_ordering = pusher_config .last_stream_ordering
369
+ user_id = pusher . user_id
370
+ last_stream_ordering = pusher .last_stream_ordering
366
371
if last_stream_ordering :
367
372
have_notifs = await self .store .get_if_maybe_push_in_range_for_user (
368
373
user_id , last_stream_ordering
@@ -372,9 +377,9 @@ async def _start_pusher(self, pusher_config: PusherConfig) -> Optional[Pusher]:
372
377
# risk missing push.
373
378
have_notifs = True
374
379
375
- p .on_started (have_notifs )
380
+ pusher .on_started (have_notifs )
376
381
377
- return p
382
+ return pusher
378
383
379
384
async def remove_pusher (self , app_id : str , pushkey : str , user_id : str ) -> None :
380
385
appid_pushkey = "%s:%s" % (app_id , pushkey )
0 commit comments