add missing AP routes

Adds routes for "/outbox", "/following", and "/followers"
This commit is contained in:
Izalia Mae 2024-06-12 13:23:53 -04:00
parent 62555b3591
commit 0d50215fc1
2 changed files with 34 additions and 0 deletions

View file

@ -148,6 +148,7 @@ class Message(aputils.Message):
'followers': f'https://{host}/followers',
'following': f'https://{host}/following',
'inbox': f'https://{host}/inbox',
'outbox': f'https://{host}/outbox',
'url': f'https://{host}/',
'endpoints': {
'sharedInbox': f'https://{host}/inbox'

View file

@ -125,6 +125,39 @@ class ActorView(View):
return None
@register_route('/outbox')
class OutboxView(View):
async def get(self, request: Request) -> Response:
msg = aputils.Message.new(
aputils.ObjectType.ORDERED_COLLECTION,
{
"id": f'https://{self.config.domain}/outbox',
"totalItems": 0,
"orderedItems": []
}
)
return Response.new(msg, ctype = 'activity')
@register_route('/following', '/followers')
class RelationshipView(View):
async def get(self, request: Request) -> Response:
with self.database.session(False) as s:
inboxes = [row['actor'] for row in s.get_inboxes()]
msg = aputils.Message.new(
aputils.ObjectType.COLLECTION,
{
"id": f'https://{self.config.domain}{request.path}',
"totalItems": len(inboxes),
"items": inboxes
}
)
return Response.new(msg, ctype = 'activity')
@register_route('/.well-known/webfinger')
class WebfingerView(View):
async def get(self, request: Request) -> Response: