Files
wanderer/web/src/routes/.well-known/webfinger/+server.ts
Flomp 9276690d60 Federation (#327)
* initial commit federation

* more federation

* more federation

* more federation

* completes follow, accept, undo

* add trail create activity

* process trail create activity

* more trail create activity

* adds missing endpoints

* adds update and delete activity

* adds comment activities

* adds activities back

* adds summit logs activities

* deletes follow counts table

* fixes migrations

* fixes migrations

* fixes migrations

* fixes migrations

* adds remote profiles

* ctd

* ctd

* we are getting closer...

* adds public summit logs

* fixes federated trails in lists

* adds remote lists

* adds list activites

* fixes lists

* adds notifications

* adds iri redirect

* fixes comments and summitlogs

* fixes follows and profiles

* adds asynchronous send

* fixes list search

* adds encryption key

* bug fixes

* fixes activity signing

* removes custon activity object types

* adds html editor

* fixes html editor

* fixes display issues on mastodon

* adds federated sharing

* finishes announcements

* fixes small summit log issues

* adds trail likes

* finalizes likes

* fixes images for komoot

* add disable federation option

* adds private profiles

* updates docs

* adds federated comments

* adds trail and comments actvitiypub routes

* adds mentions to editor

* adds mentions to trails, comments, summit logs

* updates theme

* updates theme

* update docs

* update docs

* updates docs

* fixes various frontend problems

* fixes activitypub follows api

* updates docs

* updates docs

---------

Co-authored-by: Christian Beutel <>
2025-06-21 10:09:22 +02:00

55 lines
1.7 KiB
TypeScript

import { error, json, RequestEvent } from '@sveltejs/kit';
import type PocketBase from "PocketBase";
// @ts-ignore
import { env } from "$env/dynamic/private"
// @ts-ignore
import { env as publicEnv } from '$env/dynamic/public';
// @ts-ignore
import { handleError } from "$lib/util/api_util";
// @ts-ignore
import { splitUsername } from "$lib/util/activitypub_util";
// @ts-ignore
import type { WebfingerResponse } from '$lib/models/activitypub/webfinger_response';
export async function GET(event: RequestEvent) {
try {
const resource = event.url.searchParams.get("resource")
if (!resource || !resource.startsWith("acct:")) {
return error(400, "Bad request");
}
const hostname = new URL(env.ORIGIN).hostname;
const [username, domain] = splitUsername(resource.replace("acct:", ""))
if (hostname !== domain) {
return json({ message: "Not found" }, { status: 404 });
}
const id = `${env.ORIGIN}/api/v1/activitypub/user/${username.toLowerCase()}`
const actor = await event.locals.pb.collection("activitypub_actors").getFirstListItem(`iri='${id}'`)
const r: WebfingerResponse = {
subject: resource,
aliases: [id],
links: [
{
rel: 'self',
type: 'application/activity+json',
href: id,
},
{
rel: 'http://webfinger.net/rel/profile-page',
type: 'text/html',
href: `${env.ORIGIN}/profile/@${username.toLowerCase()}`,
},
],
}
return json(r)
} catch (err) {
return handleError(err)
}
}