Adds favorit handling

This commit is contained in:
Mouse Reeve
2020-02-19 00:13:06 -08:00
parent 27b9326dd9
commit a664ad3328
10 changed files with 59 additions and 8 deletions

View File

@ -160,7 +160,7 @@ def handle_review(user, book, name, content, rating):
def handle_comment(user, review, content):
''' post a review '''
''' respond to a review or status '''
# validated and saves the comment in the database so it has an id
comment = create_status(user, content, reply_parent=review)
comment_activity = activitypub.get_status(comment)
@ -169,3 +169,14 @@ def handle_comment(user, review, content):
recipients = get_recipients(user, 'public')
broadcast(user, create_activity, recipients)
def handle_outgoing_favorite(user, status):
''' a user likes a status '''
favorite = models.Favorite.objects.create(
status=status,
user=user
)
fav_activity = activitypub.get_favorite(favorite)
recipients = get_recipients(user, 'direct', [status.user])
broadcast(user, fav_activity, recipients)