mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 21:11:16 +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:
|
elif not user.local:
|
||||||
try:
|
try:
|
||||||
status = create_status_from_activity(user, activity['object'])
|
status = create_status_from_activity(user, activity['object'])
|
||||||
if status.reply_parent:
|
if status and status.reply_parent:
|
||||||
create_notification(
|
create_notification(
|
||||||
status.reply_parent.user,
|
status.reply_parent.user,
|
||||||
'REPLY',
|
'REPLY',
|
||||||
|
|
|
@ -48,9 +48,10 @@ def create_status_from_activity(author, activity):
|
||||||
reply_parent = get_status(reply_parent_id)
|
reply_parent = get_status(reply_parent_id)
|
||||||
|
|
||||||
remote_id = activity['id']
|
remote_id = activity['id']
|
||||||
|
if models.Status.objects.filter(remote_id=remote_id).count():
|
||||||
status = create_status(author, content, reply_parent=reply_parent)
|
return None
|
||||||
status.remote_id = remote_id
|
status = create_status(author, content, reply_parent=reply_parent,
|
||||||
|
remote_id=remote_id)
|
||||||
status.published_date = activity.get('published')
|
status.published_date = activity.get('published')
|
||||||
status.save()
|
status.save()
|
||||||
return status
|
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 '''
|
''' a status update '''
|
||||||
# TODO: handle @'ing users
|
# TODO: handle @'ing users
|
||||||
|
|
||||||
|
@ -93,6 +95,7 @@ def create_status(user, content, reply_parent=None, mention_books=None):
|
||||||
user=user,
|
user=user,
|
||||||
content=content,
|
content=content,
|
||||||
reply_parent=reply_parent,
|
reply_parent=reply_parent,
|
||||||
|
remote_id=remote_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
if mention_books:
|
if mention_books:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
{% if status.status_type == 'Review' %}<h4>{{ status.name }}
|
{% if status.status_type == 'Review' %}<h4>{{ status.name }}
|
||||||
<small>{{ status.rating | stars }} stars, by {% include 'snippets/username.html' with user=status.user %}</small>
|
<small>{{ status.rating | stars }} stars, by {% include 'snippets/username.html' with user=status.user %}</small>
|
||||||
</h4>{% endif %}
|
</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 %}
|
{% 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 %}
|
{% include 'snippets/interaction.html' with activity=status %}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue