mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Handle and ignore duplicate follower error.
This commit is contained in:
parent
e0266cb754
commit
25e49d8ba2
1 changed files with 14 additions and 6 deletions
|
@ -6,6 +6,7 @@ from Crypto.Hash import SHA256
|
||||||
from django.http import HttpResponse, HttpResponseBadRequest, \
|
from django.http import HttpResponse, HttpResponseBadRequest, \
|
||||||
HttpResponseNotFound, JsonResponse
|
HttpResponseNotFound, JsonResponse
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
import django.db.utils
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -198,12 +199,19 @@ def handle_incoming_follow(activity):
|
||||||
# figure out who they are
|
# figure out who they are
|
||||||
user = get_or_create_remote_user(activity['actor'])
|
user = get_or_create_remote_user(activity['actor'])
|
||||||
# TODO: allow users to manually approve requests
|
# TODO: allow users to manually approve requests
|
||||||
models.UserRelationship.objects.create(
|
try:
|
||||||
user_subject=to_follow,
|
models.UserRelationship.objects.create(
|
||||||
user_object=user,
|
user_subject=to_follow,
|
||||||
status='follow_request',
|
user_object=user,
|
||||||
relationship_id=activity['id']
|
status='follow_request',
|
||||||
)
|
relationship_id=activity['id']
|
||||||
|
)
|
||||||
|
except django.db.utils.IntegrityError:
|
||||||
|
# Duplicate follow request. Not sure what the correct behaviour is, but just dropping
|
||||||
|
# it works for now. We should perhaps generate the Accept, but then do we need to match
|
||||||
|
# the activity id?
|
||||||
|
return HttpResponse()
|
||||||
|
|
||||||
outgoing.handle_outgoing_accept(user, to_follow, activity)
|
outgoing.handle_outgoing_accept(user, to_follow, activity)
|
||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue