forked from mirrors/bookwyrm
Only accept Create Status activities related to existing statuses
This commit is contained in:
parent
aaa44d1db0
commit
bcd54f52f3
1 changed files with 10 additions and 9 deletions
|
@ -14,7 +14,6 @@ from fedireads import models, outgoing
|
||||||
from fedireads import status as status_builder
|
from fedireads import status as status_builder
|
||||||
from fedireads.remote_user import get_or_create_remote_user
|
from fedireads.remote_user import get_or_create_remote_user
|
||||||
from fedireads.tasks import app
|
from fedireads.tasks import app
|
||||||
from fedireads.status import create_notification
|
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
@ -219,11 +218,11 @@ def handle_create(activity):
|
||||||
user = get_or_create_remote_user(activity['actor'])
|
user = get_or_create_remote_user(activity['actor'])
|
||||||
|
|
||||||
if not 'object' in activity:
|
if not 'object' in activity:
|
||||||
return HttpResponseBadRequest()
|
return False
|
||||||
|
|
||||||
if user.local:
|
if user.local:
|
||||||
# we really oughtn't even be sending in this case
|
# we really oughtn't even be sending in this case
|
||||||
return
|
return True
|
||||||
|
|
||||||
if activity['object'].get('fedireadsType') and \
|
if activity['object'].get('fedireadsType') and \
|
||||||
'inReplyToBook' in activity['object']:
|
'inReplyToBook' in activity['object']:
|
||||||
|
@ -238,10 +237,12 @@ def handle_create(activity):
|
||||||
# create the status, it'll throw a valueerror if anything is missing
|
# create the status, it'll throw a valueerror if anything is missing
|
||||||
builder(user, activity['object'])
|
builder(user, activity['object'])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return HttpResponseBadRequest()
|
return False
|
||||||
else:
|
elif activity['object'].get('inReplyTo'):
|
||||||
# TODO: should only create notes if they are relevent to a book,
|
# only create the status if it's in reply to a status we already know
|
||||||
# so, not every single thing someone posts on mastodon
|
if not status_builder.get_status(activity['object']['inReplyTo']):
|
||||||
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
status = status_builder.create_status_from_activity(
|
status = status_builder.create_status_from_activity(
|
||||||
user,
|
user,
|
||||||
|
@ -255,8 +256,8 @@ def handle_create(activity):
|
||||||
related_status=status,
|
related_status=status,
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return HttpResponseBadRequest()
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
|
|
Loading…
Reference in a new issue