Boosts - handle url, store in database, send, notify.

This commit is contained in:
Adam Kelly
2020-03-30 15:13:32 +01:00
parent 84d7e7c394
commit 745ca7d4ff
11 changed files with 133 additions and 2 deletions

View File

@ -38,6 +38,7 @@ def shared_inbox(request):
'Reject': handle_follow_reject,
'Create': handle_create,
'Like': handle_favorite,
'Announce': handle_boost,
'Add': {
'Tag': handle_add,
},
@ -286,6 +287,27 @@ def handle_unfavorite(activity):
return HttpResponse()
def handle_boost(activity):
''' someone gave us a boost! '''
try:
status_id = activity['object'].split('/')[-1]
status = models.Status.objects.get(id=status_id)
booster = get_or_create_remote_user(activity['actor'])
except (models.Status.DoesNotExist, models.User.DoesNotExist):
return HttpResponseNotFound()
if not booster.local:
status_builder.create_boost_from_activity(booster, activity)
status_builder.create_notification(
status.user,
'BOOST',
related_user=booster,
related_status=status,
)
return HttpResponse()
def handle_add(activity):
''' someone is tagging or shelving a book '''
if activity['object']['type'] == 'Tag':