mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 21:11:16 +00:00
Simplifies incoming activity handler
This commit is contained in:
parent
9aada80c05
commit
84d7e7c394
1 changed files with 14 additions and 14 deletions
|
@ -38,23 +38,23 @@ def shared_inbox(request):
|
||||||
'Reject': handle_follow_reject,
|
'Reject': handle_follow_reject,
|
||||||
'Create': handle_create,
|
'Create': handle_create,
|
||||||
'Like': handle_favorite,
|
'Like': handle_favorite,
|
||||||
'Add': handle_add,
|
'Add': {
|
||||||
|
'Tag': handle_add,
|
||||||
|
},
|
||||||
|
'Undo': {
|
||||||
|
'Follow': handle_unfollow,
|
||||||
|
'Like': handle_unfavorite,
|
||||||
|
},
|
||||||
|
'Update': {
|
||||||
|
'Person': None,# TODO: handle_update_user
|
||||||
|
'Document': None# TODO: handle_update_book
|
||||||
|
},
|
||||||
}
|
}
|
||||||
activity_type = activity['type']
|
activity_type = activity['type']
|
||||||
|
|
||||||
handler = None
|
handler = handlers.get(activity_type, None)
|
||||||
if activity_type in handlers:
|
if isinstance(handler, dict):
|
||||||
handler = handlers[activity_type]
|
handler = handler.get(activity['object']['type'], None)
|
||||||
elif activity_type == 'Undo' and 'object' in activity:
|
|
||||||
if activity['object']['type'] == 'Follow':
|
|
||||||
handler = handle_unfollow
|
|
||||||
elif activity['object']['type'] == 'Like':
|
|
||||||
handler = handle_unfavorite
|
|
||||||
elif activity_type == 'Update' and 'object' in activity:
|
|
||||||
if activity['object']['type'] == 'Person':
|
|
||||||
handler = None# TODO: handle_update_user
|
|
||||||
elif activity_type['object']['type'] == 'Book':
|
|
||||||
handler = None# TODO: handle_update_book
|
|
||||||
|
|
||||||
if handler:
|
if handler:
|
||||||
return handler(activity)
|
return handler(activity)
|
||||||
|
|
Loading…
Reference in a new issue