outposts: fix reload notification not working due to wrong ID being saved

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-14 11:13:04 +02:00
parent 03e134b296
commit 9939db13c3
3 changed files with 4 additions and 2 deletions

View File

@ -77,6 +77,7 @@ class OutpostConsumer(AuthJsonConsumer):
self.last_uid = uid self.last_uid = uid
state = OutpostState( state = OutpostState(
uid=uid, uid=uid,
channel_id=self.channel_name,
last_seen=datetime.now(), last_seen=datetime.now(),
_outpost=self.outpost, _outpost=self.outpost,
) )

View File

@ -409,6 +409,7 @@ class OutpostState:
"""Outpost instance state, last_seen and version""" """Outpost instance state, last_seen and version"""
uid: str uid: str
channel_id: str
last_seen: Optional[datetime] = field(default=None) last_seen: Optional[datetime] = field(default=None)
version: Optional[str] = field(default=None) version: Optional[str] = field(default=None)
version_should: Union[Version, LegacyVersion] = field(default=OUR_VERSION) version_should: Union[Version, LegacyVersion] = field(default=OUR_VERSION)

View File

@ -200,8 +200,8 @@ def _outpost_single_update(outpost: Outpost, layer=None):
if not layer: # pragma: no cover if not layer: # pragma: no cover
layer = get_channel_layer() layer = get_channel_layer()
for state in OutpostState.for_outpost(outpost): for state in OutpostState.for_outpost(outpost):
LOGGER.debug("sending update", channel=state.uid, outpost=outpost) LOGGER.debug("sending update", channel=state.channel_id, outpost=outpost)
async_to_sync(layer.send)(state.uid, {"type": "event.update"}) async_to_sync(layer.send)(state.channel_id, {"type": "event.update"})
@CELERY_APP.task() @CELERY_APP.task()