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:
marcos
2026-08-18 12:31:37 +00:00
parent 9378fe0427
commit a1aefa08c7
4 changed files with 65 additions and 0 deletions
+22
View File
@@ -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