broadcast to shared inboxes
This commit is contained in:
@ -30,6 +30,61 @@ def webfinger(request):
|
||||
})
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def shared_inbox(request):
|
||||
''' incoming activitypub events '''
|
||||
if request.method == 'GET':
|
||||
return HttpResponseNotFound()
|
||||
|
||||
# TODO: RSA key verification
|
||||
|
||||
try:
|
||||
activity = json.loads(request.body)
|
||||
except json.decoder.JSONDecodeError:
|
||||
return HttpResponseBadRequest
|
||||
|
||||
if activity['type'] == 'Add':
|
||||
return handle_incoming_shelve(activity)
|
||||
|
||||
if activity['type'] == 'Follow':
|
||||
return handle_incoming_follow(activity)
|
||||
|
||||
if activity['type'] == 'Create':
|
||||
return handle_incoming_create(activity)
|
||||
|
||||
return HttpResponse()
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def inbox(request, username):
|
||||
''' incoming activitypub events '''
|
||||
if request.method == 'GET':
|
||||
return HttpResponseNotFound()
|
||||
|
||||
# TODO: RSA key verification
|
||||
|
||||
try:
|
||||
activity = json.loads(request.body)
|
||||
except json.decoder.JSONDecodeError:
|
||||
return HttpResponseBadRequest
|
||||
|
||||
# TODO: should do some kind of checking if the user accepts
|
||||
# this action from the sender
|
||||
# but this will just throw an error if the user doesn't exist I guess
|
||||
models.User.objects.get(localname=username)
|
||||
|
||||
if activity['type'] == 'Add':
|
||||
return handle_incoming_shelve(activity)
|
||||
|
||||
if activity['type'] == 'Follow':
|
||||
return handle_incoming_follow(activity)
|
||||
|
||||
if activity['type'] == 'Create':
|
||||
return handle_incoming_create(activity)
|
||||
|
||||
return HttpResponse()
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def get_actor(request, username):
|
||||
''' return an activitypub actor object '''
|
||||
@ -61,37 +116,6 @@ def get_actor(request, username):
|
||||
})
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def inbox(request, username):
|
||||
''' incoming activitypub events '''
|
||||
if request.method == 'GET':
|
||||
# TODO: return a collection of something?
|
||||
return JsonResponse({})
|
||||
|
||||
# TODO: RSA key verification
|
||||
|
||||
try:
|
||||
activity = json.loads(request.body)
|
||||
except json.decoder.JSONDecodeError:
|
||||
return HttpResponseBadRequest
|
||||
|
||||
# TODO: should do some kind of checking if the user accepts
|
||||
# this action from the sender
|
||||
# but this will just throw an error if the user doesn't exist I guess
|
||||
models.User.objects.get(localname=username)
|
||||
|
||||
if activity['type'] == 'Add':
|
||||
return handle_incoming_shelve(activity)
|
||||
|
||||
if activity['type'] == 'Follow':
|
||||
return handle_incoming_follow(activity)
|
||||
|
||||
if activity['type'] == 'Create':
|
||||
return handle_incoming_create(activity)
|
||||
|
||||
return HttpResponse()
|
||||
|
||||
|
||||
def handle_incoming_shelve(activity):
|
||||
''' receiving an Add activity (to shelve a book) '''
|
||||
# TODO what happens here? If it's a remote over, then I think
|
||||
|
Reference in New Issue
Block a user