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:
@@ -1,18 +1,12 @@
|
||||
import type { Actor } from '$lib/models/activitypub/actor';
|
||||
import { TrailShareCreateSchema } from '$lib/models/api/trail_share_schema';
|
||||
import type { TrailShare } from '$lib/models/trail_share';
|
||||
import type { UserAnonymous } from '$lib/models/user';
|
||||
import { Collection, handleError, list, create } from '$lib/util/api_util';
|
||||
import { Collection, create, handleError, list } from '$lib/util/api_util';
|
||||
import { json, type RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
try {
|
||||
const r = await list<TrailShare>(event, Collection.trail_share);
|
||||
for (const share of r.items) {
|
||||
const anonymous_user = await event.locals.pb.collection('users_anonymous').getOne<UserAnonymous>(share.user)
|
||||
share.expand = {
|
||||
user: anonymous_user
|
||||
}
|
||||
}
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
handleError(e)
|
||||
@@ -21,9 +15,16 @@ export async function GET(event: RequestEvent) {
|
||||
|
||||
export async function PUT(event: RequestEvent) {
|
||||
try {
|
||||
const r = await create<TrailShare>(event, TrailShareCreateSchema, Collection.trail_share)
|
||||
const data = await event.request.json();
|
||||
const safeData = TrailShareCreateSchema.parse(data);
|
||||
|
||||
const { actor }: { actor: Actor } = await event.locals.pb.send(`/activitypub/actor?iri=${safeData.actor}`, { method: "GET", fetch: event.fetch, });
|
||||
safeData.actor = actor.id!;
|
||||
|
||||
const r = await event.locals.pb.collection(Collection.trail_share).create<TrailShare>(safeData)
|
||||
|
||||
return json(r);
|
||||
} catch (e) {
|
||||
throw handleError(e)
|
||||
return handleError(e)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ export async function GET(event: RequestEvent) {
|
||||
const r = await show<TrailShare>(event, Collection.trail_share)
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
throw handleError(e)
|
||||
return handleError(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function POST(event: RequestEvent) {
|
||||
const r = await update<TrailShare>(event, TrailShareUpdateSchema, Collection.trail_share)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw handleError(e)
|
||||
return handleError(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ export async function DELETE(event: RequestEvent) {
|
||||
const r = await remove(event, Collection.trail_share)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw handleError(e)
|
||||
return handleError(e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user