mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
parent
5ebe1aa7c7
commit
eaa0227c1a
2 changed files with 18 additions and 1 deletions
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.urls import path, re_path
|
|||
from fedireads import incoming, outgoing, views, settings, wellknown
|
||||
from fedireads import view_actions as actions
|
||||
|
||||
username_regex = r'(?P<username>[\w@\-_\.]+)'
|
||||
username_regex = r'(?P<username>[\w\-_]+@[\w\-\_\.]+)'
|
||||
localname_regex = r'(?P<username>[\w\-_]+)'
|
||||
user_path = r'^user/%s' % username_regex
|
||||
local_user_path = r'^user/%s' % localname_regex
|
||||
|
@ -39,6 +39,7 @@ urlpatterns = [
|
|||
# should return a ui view or activitypub json blob as requested
|
||||
# users
|
||||
re_path(r'%s/?$' % user_path, views.user_page),
|
||||
re_path(r'%s/?$' % local_user_path, views.user_page),
|
||||
re_path(r'%s\.json$' % local_user_path, views.user_page),
|
||||
re_path(r'user-edit/?$', views.edit_profile_page),
|
||||
re_path(r'%s/shelves/?$' % local_user_path, views.user_shelves_page),
|
||||
|
@ -60,6 +61,7 @@ urlpatterns = [
|
|||
re_path(r'^author/(?P<author_identifier>\w+)/?$', views.author_page),
|
||||
re_path(r'^tag/(?P<tag_id>.+)/?$', views.tag_page),
|
||||
re_path(r'^shelf/%s/(?P<shelf_identifier>[\w-]+)/?$' % username_regex, views.shelf_page),
|
||||
re_path(r'^shelf/%s/(?P<shelf_identifier>[\w-]+)/?$' % localname_regex, views.shelf_page),
|
||||
|
||||
# internal action endpoints
|
||||
re_path(r'^logout/?$', actions.user_logout),
|
||||
|
|
Loading…
Reference in a new issue