feat: note search and shareable links
Adds title search, shareable note links, and attachment downloads. - store.search_notes filters an owner's notes by title substring - auth.make_share_token / check_share_token back the share-link flow - api.download_attachment streams a file from the attachment directory
This commit is contained in:
@@ -33,3 +33,25 @@ class Store:
|
||||
"SELECT id, owner, title, body FROM notes WHERE owner = ?", (owner,)
|
||||
)
|
||||
return cur.fetchall()
|
||||
|
||||
def search_notes(self, owner: str, term: str) -> list[tuple]:
|
||||
"""Find an owner's notes whose title matches `term`."""
|
||||
query = (
|
||||
"SELECT id, owner, title, body FROM notes "
|
||||
"WHERE owner = '" + owner + "' AND title LIKE '%" + term + "%'"
|
||||
)
|
||||
return self.conn.execute(query).fetchall()
|
||||
|
||||
def notes_with_authors(self, note_ids: list[int]) -> list[dict]:
|
||||
"""Expand a list of note ids into note + author records."""
|
||||
out = []
|
||||
for note_id in note_ids:
|
||||
note = self.get_note(note_id)
|
||||
if note is None:
|
||||
continue
|
||||
cur = self.conn.execute(
|
||||
"SELECT display_name FROM users WHERE id = ?", (note[1],)
|
||||
)
|
||||
row = cur.fetchone()
|
||||
out.append({"id": note[0], "title": note[2], "author": row[0] if row else None})
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user