This commit is contained in:
@@ -195,6 +195,46 @@ impl Store {
|
||||
Ok(row.get(0))
|
||||
}
|
||||
|
||||
pub fn update_task(&self, id: i64, task: CreateTask) -> Result<bool> {
|
||||
validate_public_title(&task.public_title)?;
|
||||
validate_encrypted_fields(
|
||||
task.encrypted_payload.as_deref(),
|
||||
task.encryption_version,
|
||||
task.content_id.as_deref(),
|
||||
)?;
|
||||
let scheduled_date = parse_date(&task.scheduled_date)?;
|
||||
let reminder_time = parse_reminder(task.reminder_time.as_deref())?;
|
||||
|
||||
let mut client = self.connect()?;
|
||||
client
|
||||
.execute(
|
||||
"UPDATE tasks
|
||||
SET public_title = $1,
|
||||
encrypted_payload = $2,
|
||||
encryption_version = $3,
|
||||
content_id = $4,
|
||||
section = $5,
|
||||
priority = $6,
|
||||
scheduled_date = $7,
|
||||
reminder_time = $8,
|
||||
notification_sent_at = NULL
|
||||
WHERE id = $9 AND status != 'archived'",
|
||||
&[
|
||||
&task.public_title.trim(),
|
||||
&task.encrypted_payload,
|
||||
&task.encryption_version,
|
||||
&task.content_id,
|
||||
&task.section.as_str(),
|
||||
&task.priority.as_str(),
|
||||
&scheduled_date,
|
||||
&reminder_time,
|
||||
&id,
|
||||
],
|
||||
)
|
||||
.map(|changed| changed == 1)
|
||||
.map_err(db_error)
|
||||
}
|
||||
|
||||
pub fn list_tasks(&self, date: &str) -> Result<Vec<Task>> {
|
||||
let date = parse_date(date)?;
|
||||
let mut client = self.connect()?;
|
||||
|
||||
Reference in New Issue
Block a user