feat: add POST /notes/feed endpoint for multi-DID filtering

This commit is contained in:
Julien Calixte
2026-03-10 15:51:10 +01:00
parent 425dd96872
commit 06ac3142a8
2 changed files with 29 additions and 0 deletions

View File

@@ -49,6 +49,23 @@ export const getNotesByDid = (did: string, cursor?: string, limit = 20) => {
};
};
export const getNotesByDids = (dids: string[], cursor?: string, limit = 20) => {
if (dids.length === 0) return { notes: [] };
const placeholders = dids.map(() => "?").join(", ");
const notes = cursor
? db.prepare(
`SELECT did, rkey, title, publishedAt, createdAt, language FROM note WHERE discoverable = 1 AND did IN (${placeholders}) AND rkey < ? ORDER BY rkey DESC LIMIT ?`,
).all<NoteRow>(...dids, cursor, limit)
: db.prepare(
`SELECT did, rkey, title, publishedAt, createdAt, language FROM note WHERE discoverable = 1 AND did IN (${placeholders}) ORDER BY rkey DESC LIMIT ?`,
).all<NoteRow>(...dids, limit);
return {
notes,
cursor: notes.length === limit ? notes[notes.length - 1].rkey : undefined,
};
};
export const deleteNote = ({ did, rkey }: { did: string; rkey: string }) => {
db.exec("DELETE FROM note WHERE did = ? AND rkey = ?", did, rkey);
};