feat: add POST /notes/feed endpoint for multi-DID filtering
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user