1
0
Fork 0
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

@ -5,4 +5,4 @@ from .collection import get_outbox, get_outbox_page, get_add, get_remove, \
from .create import get_create
from .follow import get_follow_request, get_unfollow, get_accept
from .status import get_review, get_review_article, get_status, get_replies, \
get_favorite
get_favorite, get_add_tag, get_remove_tag

View file

@ -118,6 +118,7 @@ def get_add_remove(user, book, shelf, action='Add'):
'type': action,
'actor': user.actor,
'object': {
# TODO: document??
'type': 'Document',
'name': book.data['title'],
'url': book.openlibrary_key

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,
}
}