From 4710e65269e92d8b490a904d5ce1d1b1b3706c1a Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 7 Nov 2020 19:15:04 -0800 Subject: [PATCH] create notification for local favs/boosts --- bookwyrm/incoming.py | 9 ++++----- bookwyrm/outgoing.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bookwyrm/incoming.py b/bookwyrm/incoming.py index bcb021ca7..8eca4cfbf 100644 --- a/bookwyrm/incoming.py +++ b/bookwyrm/incoming.py @@ -269,11 +269,10 @@ def handle_favorite(activity): @app.task def handle_unfavorite(activity): ''' approval of your good good post ''' - try: - like = models.Favorite.objects.filter( - remote_id=activity['object']['id'] - ).first() - except models.Favorite.DoesNotExist: + like = models.Favorite.objects.filter( + remote_id=activity['object']['id'] + ).first() + if not like: return like.delete() diff --git a/bookwyrm/outgoing.py b/bookwyrm/outgoing.py index c0253a99a..a196fcecf 100644 --- a/bookwyrm/outgoing.py +++ b/bookwyrm/outgoing.py @@ -286,6 +286,12 @@ def handle_favorite(user, status): fav_activity = favorite.to_activity() broadcast( user, fav_activity, privacy='direct', direct_recipients=[status.user]) + create_notification( + status.user, + 'FAVORITE', + related_user=user, + related_status=status + ) def handle_unfavorite(user, status): @@ -319,6 +325,13 @@ def handle_boost(user, status): boost_activity = boost.to_activity() broadcast(user, boost_activity) + create_notification( + status.user, + 'BOOST', + related_user=user, + related_status=status + ) + def handle_unboost(user, status): ''' a user regrets boosting a status '''