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:
23
web/src/routes/api/v1/trail-like/+server.ts
Normal file
23
web/src/routes/api/v1/trail-like/+server.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { TrailLikeCreateSchema } from '$lib/models/api/trail_like_schema';
|
||||
import type { TrailLike } from '$lib/models/trail_like';
|
||||
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<TrailLike>(event, Collection.trail_share);
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
handleError(e)
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(event: RequestEvent) {
|
||||
try {
|
||||
const r = await create<TrailLike>(event, TrailLikeCreateSchema, Collection.trail_like)
|
||||
|
||||
return json(r);
|
||||
} catch (e) {
|
||||
return handleError(e)
|
||||
}
|
||||
}
|
||||
21
web/src/routes/api/v1/trail-like/[id]/+server.ts
Normal file
21
web/src/routes/api/v1/trail-like/[id]/+server.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { TrailLike } from "$lib/models/trail_like";
|
||||
import { Collection, handleError, remove, show } from "$lib/util/api_util";
|
||||
import { json, type RequestEvent } from "@sveltejs/kit";
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
try {
|
||||
const r = await show<TrailLike>(event, Collection.trail_like)
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
return handleError(e)
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(event: RequestEvent) {
|
||||
try {
|
||||
const r = await remove(event, Collection.trail_like)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
return handleError(e)
|
||||
}
|
||||
}
|
||||
21
web/src/routes/api/v1/trail-like/delete/+server.ts
Normal file
21
web/src/routes/api/v1/trail-like/delete/+server.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { TrailLikeCreateSchema } from '$lib/models/api/trail_like_schema';
|
||||
import { Collection, handleError } from '$lib/util/api_util';
|
||||
import { json, type RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
|
||||
// this route exists so we can delete a like without knowing its ID
|
||||
export async function POST(event: RequestEvent) {
|
||||
try {
|
||||
|
||||
const data = await event.request.json();
|
||||
const safeData = TrailLikeCreateSchema.parse(data);
|
||||
|
||||
const like = await event.locals.pb.collection(Collection.trail_like).getFirstListItem(`actor='${safeData.actor}'&&trail='${safeData.trail}'`)
|
||||
|
||||
const r = await event.locals.pb.collection(Collection.trail_like).delete(like.id)
|
||||
|
||||
return json({ 'acknowledged': r })
|
||||
} catch (e: any) {
|
||||
handleError(e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user