Adds avatars to activitypub actor

Fixes #45
This commit is contained in:
Mouse Reeve
2020-03-27 09:58:25 -07:00
parent 5ebe1aa7c7
commit eaa0227c1a
2 changed files with 18 additions and 1 deletions

View File

@ -1,7 +1,17 @@
''' actor serializer '''
from fedireads.settings import DOMAIN
def get_actor(user):
''' activitypub actor from db User '''
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)
return {
'@context': [
'https://www.w3.org/ns/activitystreams',
@ -33,5 +43,10 @@ def get_actor(user):
},
'fedireadsUser': True,
'manuallyApprovesFollowers': user.manually_approves_followers,
"icon": {
"type": "Image",
"mediaType": icon_type,
"url": icon_url,
},
}