move things into different files

This commit is contained in:
Mouse Reeve
2020-02-11 15:17:21 -08:00
parent 28198e628c
commit a1fbba1ba3
12 changed files with 330 additions and 315 deletions

View File

@ -11,17 +11,11 @@ import requests
from uuid import uuid4
from fedireads import models
from fedireads.api import get_or_create_remote_user
from fedireads.remote_user import get_or_create_remote_user
from fedireads.openlibrary import get_or_create_book
from fedireads.settings import DOMAIN
# TODO: this should probably live somewhere else
class HttpResponseUnauthorized(HttpResponse):
''' http response for authentication failure '''
status_code = 401
def webfinger(request):
''' allow other servers to ask about a user '''
resource = request.GET.get('resource')
@ -72,7 +66,7 @@ def shared_inbox(request):
headers={'Accept': 'application/activity+json'}
)
if not response.ok:
return HttpResponseUnauthorized()
return HttpResponse(status=401)
actor = response.json()
key = RSA.import_key(actor['publicKey']['publicKeyPem'])
@ -94,7 +88,7 @@ def shared_inbox(request):
try:
signer.verify(digest, signature)
except ValueError:
return HttpResponseUnauthorized()
return HttpResponse(status=401)
if activity['type'] == 'Add':
return handle_incoming_shelve(activity)