Skip to content

Commit

Permalink
login: recreate listeners after re-login
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Mar 15, 2023
1 parent b8d79a6 commit f5aee18
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion linkedin_matrix/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ async def is_logged_in(self) -> bool:

async def on_logged_in(self, client: LinkedInMessaging):
self.client = client
self.listener_event_handlers_created = False
self.user_profile_cache = await self.client.get_user_profile()
if (mp := self.user_profile_cache.mini_profile) and mp.entity_urn:
self.li_member_urn = mp.entity_urn
Expand Down Expand Up @@ -297,10 +298,10 @@ async def logout(self):
pass
self._track_metric(METRIC_LOGGED_IN, True)
self.client = None
self.listener_event_handlers_created = False
self.user_profile_cache = None
self.li_member_urn = None
self.notice_room = None
self.listener_event_handlers_created = False
await self.save()
self._is_logging_out = False

Expand Down Expand Up @@ -528,10 +529,12 @@ def start_listen(self):
self.listen_task.add_done_callback(self.on_listen_task_end)

async def _try_listen(self):
self.log.info("Trying to start the listener")
if not self.client:
self.log.error("No client, cannot start listener!")
return
if not self.listener_event_handlers_created:
self.log.info("Adding listeners to client")
self.client.add_event_listener("ALL_EVENTS", self.handle_linkedin_stream_event)
self.client.add_event_listener("event", self.handle_linkedin_event)
self.client.add_event_listener("reactionAdded", self.handle_linkedin_reaction_added)
Expand Down

0 comments on commit f5aee18

Please sign in to comment.