Works on #55
This commit is contained in:
Mouse Reeve
2020-02-20 22:19:19 -08:00
parent 13b512b569
commit 870d0b9697
15 changed files with 205 additions and 37 deletions

View File

@ -1,4 +1,7 @@
''' status serializers '''
from uuid import uuid4
def get_review(review):
''' fedireads json for book reviews '''
status = get_status(review)
@ -76,9 +79,51 @@ def get_replies(status, replies):
def get_favorite(favorite):
''' like a post '''
return {
"@context": "https://www.w3.org/ns/activitystreams",
"id": favorite.absolute_id,
"type": "Like",
"actor": favorite.user.actor,
"object": favorite.status.absolute_id,
'@context': 'https://www.w3.org/ns/activitystreams',
'id': favorite.absolute_id,
'type': 'Like',
'actor': favorite.user.actor,
'object': favorite.status.absolute_id,
}
def get_add_tag(tag):
''' add activity for tagging a book '''
uuid = uuid4()
return {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': str(uuid),
'type': 'Add',
'actor': tag.user.actor,
'object': {
'type': 'Tag',
'id': tag.absolute_id,
'name': tag.name,
},
'target': {
'type': 'Book',
'id': tag.book.absolute_id,
}
}
def get_remove_tag(tag):
''' add activity for tagging a book '''
uuid = uuid4()
return {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': str(uuid),
'type': 'Remove',
'actor': tag.user.actor,
'object': {
'type': 'Tag',
'id': tag.absolute_id,
'name': tag.name,
},
'target': {
'type': 'Book',
'id': tag.book.absolute_id,
}
}