mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 00:26:33 +00:00
20662a90dd
Work on checking incoming / outgoing will work alone.
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
''' makin' freinds inthe ap json format '''
|
|
from uuid import uuid4
|
|
|
|
from fedireads.settings import DOMAIN
|
|
|
|
|
|
def get_follow_request(user, to_follow):
|
|
''' a local user wants to follow someone '''
|
|
uuid = uuid4()
|
|
return {
|
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
|
'id': 'https://%s/%s' % (DOMAIN, str(uuid)),
|
|
'summary': '',
|
|
'type': 'Follow',
|
|
'actor': user.actor,
|
|
'object': to_follow.actor,
|
|
}
|
|
|
|
def get_unfollow(relationship):
|
|
''' undo that precious bond of friendship '''
|
|
return {
|
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
|
'id': '%s/undo' % relationship.absolute_id,
|
|
'type': 'Undo',
|
|
'actor': relationship.user_subject.actor,
|
|
'object': {
|
|
'id': relationship.relationship_id,
|
|
'type': 'Follow',
|
|
'actor': relationship.user_subject.actor,
|
|
'object': relationship.user_object.actor,
|
|
}
|
|
}
|
|
|
|
|
|
def get_accept(user, relationship):
|
|
''' accept a follow request '''
|
|
return {
|
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
|
'id': '%s#accepts/follows/' % user.absolute_id,
|
|
'type': 'Accept',
|
|
'actor': user.actor,
|
|
'object': {
|
|
'id': relationship.relationship_id,
|
|
'type': 'Follow',
|
|
'actor': relationship.user_subject.actor,
|
|
'object': relationship.user_object.actor,
|
|
}
|
|
}
|
|
|
|
|
|
def get_reject(user, relationship):
|
|
''' reject a follow request '''
|
|
return {
|
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
|
'id': '%s#rejects/follows/' % user.absolute_id,
|
|
'type': 'Reject',
|
|
'actor': user.actor,
|
|
'object': {
|
|
'id': relationship.relationship_id,
|
|
'type': 'Follow',
|
|
'actor': relationship.user_subject.actor,
|
|
'object': relationship.user_object.actor,
|
|
}
|
|
}
|