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 <>
This commit is contained in:
@@ -4,11 +4,11 @@ export async function POST(event: RequestEvent) {
|
||||
const data = await event.request.json()
|
||||
|
||||
try {
|
||||
const r = await event.locals.ms.index(event.params.index as string).search(data.q, data.options);
|
||||
const r = await event.locals.ms.index(event.params.index as string).search(data.q, data.options);
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
|
||||
|
||||
throw error(e.httpStatus, e)
|
||||
}
|
||||
}
|
||||
46
web/src/routes/api/v1/search/actor/+server.ts
Normal file
46
web/src/routes/api/v1/search/actor/+server.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type { Actor } from '$lib/models/activitypub/actor';
|
||||
import { splitUsername } from '$lib/util/activitypub_util';
|
||||
import { handleError } from '$lib/util/api_util';
|
||||
import { error, json, type RequestEvent } from '@sveltejs/kit';
|
||||
import { ClientResponseError, type ListResult } from "pocketbase"
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
try {
|
||||
|
||||
if (!event.url.searchParams.has("q")) {
|
||||
throw new ClientResponseError({ status: 400, response: "Bad request" });
|
||||
|
||||
}
|
||||
const q = event.url.searchParams.get("q")
|
||||
|
||||
const [user, domain] = splitUsername(q!)
|
||||
|
||||
let filter = `username~'${user}'`;
|
||||
|
||||
if (event.url.searchParams.get("includeSelf") == "false" && event.locals.pb.authStore.record) {
|
||||
filter += `&& id != "${event.locals.pb.authStore.record.actor}"`
|
||||
}
|
||||
|
||||
const response = await event.locals.pb.collection("activitypub_actors").getList(1, 3, { filter: filter })
|
||||
|
||||
try {
|
||||
const { actor, error } = await event.locals.pb.send(`/activitypub/actor?resource=acct:${q}&follows=false`, { method: "GET", fetch: event.fetch, });
|
||||
|
||||
if (!response.items.find(i => i.iri == actor.iri)) {
|
||||
response.items.push(actor)
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
return json({ items: response.items })
|
||||
|
||||
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.message == "fetch failed") {
|
||||
return error(404, "Not found")
|
||||
}
|
||||
return handleError(e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user