mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Don't duplicate incoming statuses
This commit is contained in:
parent
ee56ae86ec
commit
a8ea3c08c9
3 changed files with 9 additions and 6 deletions
|
@ -285,7 +285,7 @@ def handle_incoming_create(activity):
|
|||
elif not user.local:
|
||||
try:
|
||||
status = create_status_from_activity(user, activity['object'])
|
||||
if status.reply_parent:
|
||||
if status and status.reply_parent:
|
||||
create_notification(
|
||||
status.reply_parent.user,
|
||||
'REPLY',
|
||||
|
|
|
@ -48,9 +48,10 @@ def create_status_from_activity(author, activity):
|
|||
reply_parent = get_status(reply_parent_id)
|
||||
|
||||
remote_id = activity['id']
|
||||
|
||||
status = create_status(author, content, reply_parent=reply_parent)
|
||||
status.remote_id = remote_id
|
||||
if models.Status.objects.filter(remote_id=remote_id).count():
|
||||
return None
|
||||
status = create_status(author, content, reply_parent=reply_parent,
|
||||
remote_id=remote_id)
|
||||
status.published_date = activity.get('published')
|
||||
status.save()
|
||||
return status
|
||||
|
@ -80,7 +81,8 @@ def get_status(absolute_id):
|
|||
|
||||
|
||||
|
||||
def create_status(user, content, reply_parent=None, mention_books=None):
|
||||
def create_status(user, content, reply_parent=None, mention_books=None,
|
||||
remote_id=None):
|
||||
''' a status update '''
|
||||
# TODO: handle @'ing users
|
||||
|
||||
|
@ -93,6 +95,7 @@ def create_status(user, content, reply_parent=None, mention_books=None):
|
|||
user=user,
|
||||
content=content,
|
||||
reply_parent=reply_parent,
|
||||
remote_id=remote_id,
|
||||
)
|
||||
|
||||
if mention_books:
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{% if status.status_type == 'Review' %}<h4>{{ status.name }}
|
||||
<small>{{ status.rating | stars }} stars, by {% include 'snippets/username.html' with user=status.user %}</small>
|
||||
</h4>{% endif %}
|
||||
<blockquote>{{ status.content }}</blockquote>
|
||||
<blockquote>{{ status.content | safe }}</blockquote>
|
||||
{% if not max_depth and status.reply_parent or status|replies %}<p><a href="{{ status.absolute_id }}">Thread</a>{% endif %}
|
||||
{% include 'snippets/interaction.html' with activity=status %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue