feat: support updating notes and reminders
This commit is contained in:
@@ -321,6 +321,18 @@ class AssistantStorage:
|
||||
).fetchall()
|
||||
return [row_to_dict(row) for row in rows]
|
||||
|
||||
def update_note(self, user_id: int, note_id: int, text: str) -> bool:
|
||||
with self._connection() as connection:
|
||||
cursor = connection.execute(
|
||||
"""
|
||||
UPDATE notes
|
||||
SET text = ?
|
||||
WHERE user_id = ? AND id = ?
|
||||
""",
|
||||
(text, user_id, note_id),
|
||||
)
|
||||
return cursor.rowcount > 0
|
||||
|
||||
def delete_note(self, user_id: int, note_id: int) -> bool:
|
||||
with self._connection() as connection:
|
||||
cursor = connection.execute(
|
||||
@@ -366,6 +378,35 @@ class AssistantStorage:
|
||||
).fetchall()
|
||||
return [row_to_dict(row) for row in rows]
|
||||
|
||||
def update_reminder(
|
||||
self,
|
||||
user_id: int,
|
||||
reminder_id: int,
|
||||
*,
|
||||
text: str | None = None,
|
||||
remind_at_utc: datetime | None = None,
|
||||
) -> bool:
|
||||
with self._connection() as connection:
|
||||
cursor = connection.execute(
|
||||
"""
|
||||
UPDATE reminders
|
||||
SET text = COALESCE(?, text),
|
||||
remind_at = COALESCE(?, remind_at)
|
||||
WHERE user_id = ? AND id = ? AND status = 'pending'
|
||||
""",
|
||||
(
|
||||
text,
|
||||
(
|
||||
to_utc_iso(remind_at_utc)
|
||||
if remind_at_utc is not None
|
||||
else None
|
||||
),
|
||||
user_id,
|
||||
reminder_id,
|
||||
),
|
||||
)
|
||||
return cursor.rowcount > 0
|
||||
|
||||
def cancel_reminder(self, user_id: int, reminder_id: int) -> bool:
|
||||
with self._connection() as connection:
|
||||
cursor = connection.execute(
|
||||
|
||||
Reference in New Issue
Block a user