Skip to content

Commit 11de65e

Browse files
committed
fix margin lexicon
1 parent d048238 commit 11de65e

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

backend/src/config/scopes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export const SEMBLE_SCOPES = [
1919
'repo:network.cosmik.collectionLink',
2020
];
2121
export const MARGIN_SCOPES = [
22-
'repo:at.margin.bookmark',
22+
// Bookmarks are no longer a distinct collection — Margin folded them into
23+
// at.margin.note (motivation: 'bookmarking'), so we only need the note +
24+
// collection scopes.
2325
'repo:at.margin.note',
2426
'repo:at.margin.collection',
2527
'repo:at.margin.collectionItem',

backend/src/routes/integrations.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ export async function handleListSembleCollections(request: Request, env: Env): P
226226
}
227227

228228
/**
229-
* POST /api/integrations/margin/bookmarks — create an at.margin.bookmark on PDS
229+
* POST /api/integrations/margin/bookmarks — save a page to Margin.
230+
*
231+
* Margin no longer has a distinct bookmark record; bookmarks are an
232+
* at.margin.note with `motivation: 'bookmarking'` (no selector, since the whole
233+
* page is the target) and the description carried in `body.value`.
230234
*/
231235
export async function handleCreateMarginBookmark(request: Request, env: Env): Promise<Response> {
232236
const session = await getSessionFromRequest(request, env);
@@ -272,17 +276,22 @@ export async function handleCreateMarginBookmark(request: Request, env: Env): Pr
272276
: [];
273277

274278
const rkey = generateTID();
279+
const description = body.description?.trim();
275280
const record = {
276-
$type: 'at.margin.bookmark',
277-
source: body.url,
278-
title: body.title || undefined,
279-
description: body.description || undefined,
281+
$type: 'at.margin.note',
282+
motivation: 'bookmarking',
283+
target: {
284+
source: body.url,
285+
...(body.title ? { title: body.title } : {}),
286+
},
287+
...(description ? { body: { value: description, format: 'text/plain' } } : {}),
280288
tags: [],
289+
generator: { name: 'Skyreader', homepage: 'https://skyreader.app' },
281290
createdAt: new Date().toISOString(),
282291
};
283292

284293
const pdsClient = createPDSClient(session);
285-
const result = await pdsClient.putRecord('at.margin.bookmark', rkey, record);
294+
const result = await pdsClient.putRecord('at.margin.note', rkey, record);
286295

287296
if (!result.success) {
288297
return new Response(JSON.stringify({ error: result.error }), {

0 commit comments

Comments
 (0)