From f414884e008e3e08717d090d76a60eff925138d1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 14 Feb 2020 21:15:38 -0800 Subject: [PATCH] Fixes duplicate save attempt of review --- fedireads/incoming.py | 13 ++++++------- fedireads/outgoing.py | 11 +---------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/fedireads/incoming.py b/fedireads/incoming.py index 745f8a7ef..a220d3107 100644 --- a/fedireads/incoming.py +++ b/fedireads/incoming.py @@ -303,13 +303,12 @@ def handle_incoming_create(activity): 'inReplyTo' in activity['object']: response = create_review(user, activity) - if not user.local: - models.Activity( - uuid=activity['uuid'], - user=user, - content=activity, - activity_type=activity['object']['type'] - ) + models.Activity( + uuid=activity['id'], + user=user, + content=activity, + activity_type=activity['object']['type'] + ) return response diff --git a/fedireads/outgoing.py b/fedireads/outgoing.py index 5995c5733..b023521e5 100644 --- a/fedireads/outgoing.py +++ b/fedireads/outgoing.py @@ -205,6 +205,7 @@ def handle_review(user, book, name, content, rating): 'type': 'Article', 'published': datetime.utcnow().isoformat(), 'attributedTo': user.actor, + 'name': name, 'content': content, 'inReplyTo': book.openlibrary_key, # TODO is this the right identifier? 'rating': rating, # fedireads-only custom field @@ -226,15 +227,5 @@ def handle_review(user, book, name, content, rating): 'object': obj, } - models.Review( - uuid=create_uuid, - user=user, - content=activity, - activity_type='Article', - book=book, - name=name, - rating=rating, - review_content=content, - ).save() broadcast(user, activity, recipients)