From a9d12e06451c36a2a1103ea5c7b0539d7283e9fb Mon Sep 17 00:00:00 2001 From: Anson-Quek Date: Sun, 29 Jan 2023 13:40:33 +0800 Subject: [PATCH] Prevent unnecessary logging in notification stream --- weverse/weverse.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/weverse/weverse.py b/weverse/weverse.py index 1798ea6..646b1dd 100644 --- a/weverse/weverse.py +++ b/weverse/weverse.py @@ -223,7 +223,7 @@ async def _get_new_comment( try: artist_comments = await self.fetch_artist_comments(notification.post_id) - except NotFound: # This is because the Post has been deleted. + except (Forbidden, NotFound): # This is because the Post has been deleted. continue if not old_cache.get(notification.post_id + notification.author.id): @@ -589,7 +589,12 @@ async def __notification_stream(self) -> None: await self.on_new_notification(notification) if notification.post_type == NotificationType.POST: - post = await self.fetch_post(notification.post_id) + try: + post = await self.fetch_post(notification.post_id) + + except Forbidden: + continue + await self.on_new_post(post) elif notification.post_type == NotificationType.MOMENT: @@ -606,7 +611,12 @@ async def __notification_stream(self) -> None: await self.on_new_media(media) elif notification.post_type == NotificationType.LIVE: - live = await self.fetch_live(notification.post_id) + try: + live = await self.fetch_live(notification.post_id) + + except Forbidden: + continue + await self.on_new_live(live) elif notification.post_type == NotificationType.NOTICE: