2020-02-18 04:12:19 +00:00
|
|
|
''' actor serializer '''
|
2020-03-27 16:58:25 +00:00
|
|
|
from fedireads.settings import DOMAIN
|
2020-02-18 04:12:19 +00:00
|
|
|
|
|
|
|
def get_actor(user):
|
|
|
|
''' activitypub actor from db User '''
|
2020-03-27 16:58:25 +00:00
|
|
|
avatar = user.avatar
|
|
|
|
|
|
|
|
icon_path = '/static/images/default_avi.jpg'
|
|
|
|
icon_type = 'image/jpeg'
|
|
|
|
if avatar:
|
|
|
|
icon_path = avatar.url
|
|
|
|
icon_type = 'image/%s' % icon_path.split('.')[-1]
|
|
|
|
|
|
|
|
icon_url = 'https://%s%s' % (DOMAIN, icon_path)
|
2020-02-18 04:12:19 +00:00
|
|
|
return {
|
|
|
|
'@context': [
|
|
|
|
'https://www.w3.org/ns/activitystreams',
|
2020-03-13 23:15:07 +00:00
|
|
|
'https://w3id.org/security/v1',
|
|
|
|
{
|
|
|
|
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
|
|
|
"schema": "http://schema.org#",
|
|
|
|
"PropertyValue": "schema:PropertyValue",
|
|
|
|
"value": "schema:value",
|
|
|
|
},
|
2020-02-18 04:12:19 +00:00
|
|
|
],
|
|
|
|
|
2020-05-13 01:56:28 +00:00
|
|
|
'id': user.remote_id,
|
2020-02-18 04:12:19 +00:00
|
|
|
'type': 'Person',
|
|
|
|
'preferredUsername': user.localname,
|
|
|
|
'name': user.name,
|
|
|
|
'inbox': user.inbox,
|
2020-05-13 01:56:28 +00:00
|
|
|
'outbox': '%s/outbox' % user.remote_id,
|
|
|
|
'followers': '%s/followers' % user.remote_id,
|
|
|
|
'following': '%s/following' % user.remote_id,
|
2020-02-18 04:12:19 +00:00
|
|
|
'summary': user.summary,
|
|
|
|
'publicKey': {
|
2020-05-13 01:56:28 +00:00
|
|
|
'id': '%s/#main-key' % user.remote_id,
|
|
|
|
'owner': user.remote_id,
|
2020-02-18 04:12:19 +00:00
|
|
|
'publicKeyPem': user.public_key,
|
|
|
|
},
|
|
|
|
'endpoints': {
|
|
|
|
'sharedInbox': user.shared_inbox,
|
2020-02-19 19:33:00 +00:00
|
|
|
},
|
|
|
|
'fedireadsUser': True,
|
2020-03-13 23:15:07 +00:00
|
|
|
'manuallyApprovesFollowers': user.manually_approves_followers,
|
2020-03-27 16:58:25 +00:00
|
|
|
"icon": {
|
|
|
|
"type": "Image",
|
|
|
|
"mediaType": icon_type,
|
|
|
|
"url": icon_url,
|
|
|
|
},
|
2020-02-18 04:12:19 +00:00
|
|
|
}
|