* 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 <>
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import type { TrailShare } from "$lib/models/trail_share";
|
|
import { APIError } from "$lib/util/api_util";
|
|
import { type ListResult } from "pocketbase";
|
|
import { writable, type Writable } from "svelte/store";
|
|
|
|
export const shares: Writable<TrailShare[]> = writable([])
|
|
|
|
|
|
export async function trail_share_index(data: { trail?: string, actor?: string, actorIRI?: string }, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
|
let filter = ""
|
|
if (data.trail) {
|
|
filter += `trail='${data.trail}'`
|
|
} else if (data.actor) {
|
|
filter += `actor='${data.actor}'`
|
|
} else if (data.actorIRI) {
|
|
filter += `actor.iri='${data.actorIRI}'`
|
|
}
|
|
|
|
const r = await f('/api/v1/trail-share?' + new URLSearchParams({
|
|
filter: filter,
|
|
expand: "actor"
|
|
}), {
|
|
method: 'GET',
|
|
})
|
|
|
|
if (!r.ok) {
|
|
const response = await r.json();
|
|
throw new APIError(r.status, response.message, response.detail)
|
|
}
|
|
|
|
const response: ListResult<TrailShare> = await r.json();
|
|
|
|
shares.set(response.items);
|
|
|
|
return response.items;
|
|
|
|
}
|
|
|
|
export async function trail_share_create(share: TrailShare) {
|
|
let r = await fetch('/api/v1/trail-share', {
|
|
method: 'PUT',
|
|
body: JSON.stringify(share),
|
|
})
|
|
|
|
if (!r.ok) {
|
|
const response = await r.json();
|
|
throw new APIError(r.status, response.message, response.detail)
|
|
}
|
|
}
|
|
|
|
export async function trail_share_update(share: TrailShare) {
|
|
let r = await fetch('/api/v1/trail-share/' + share.id, {
|
|
method: 'POST',
|
|
body: JSON.stringify(share),
|
|
})
|
|
|
|
if (!r.ok) {
|
|
const response = await r.json();
|
|
throw new APIError(r.status, response.message, response.detail)
|
|
}
|
|
}
|
|
|
|
export async function trail_share_delete(share: TrailShare) {
|
|
const r = await fetch('/api/v1/trail-share/' + share.id, {
|
|
method: 'DELETE',
|
|
})
|
|
|
|
if (!r.ok) {
|
|
const response = await r.json();
|
|
throw new APIError(r.status, response.message, response.detail)
|
|
}
|
|
} |