This commit is contained in:
@@ -4,24 +4,41 @@ use serde::{Deserialize, Serialize};
|
||||
pub struct Task {
|
||||
pub id: i64,
|
||||
pub routine_id: Option<i64>,
|
||||
pub title: String,
|
||||
pub notes: Option<String>,
|
||||
pub public_title: String,
|
||||
pub encrypted_payload: Option<String>,
|
||||
pub encryption_version: Option<i16>,
|
||||
pub content_id: Option<String>,
|
||||
pub section: String,
|
||||
pub priority: String,
|
||||
pub scheduled_date: String,
|
||||
pub reminder_time: Option<String>,
|
||||
pub status: String,
|
||||
pub completed_at: Option<i64>,
|
||||
#[serde(skip)]
|
||||
pub private_title: Option<String>,
|
||||
#[serde(skip)]
|
||||
pub private_notes: Option<String>,
|
||||
#[serde(skip)]
|
||||
pub decryption_failed: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Routine {
|
||||
pub title: String,
|
||||
pub notes: Option<String>,
|
||||
pub public_title: String,
|
||||
pub encrypted_payload: Option<String>,
|
||||
pub encryption_version: Option<i16>,
|
||||
pub content_id: Option<String>,
|
||||
pub section: String,
|
||||
pub priority: String,
|
||||
pub schedule: Schedule,
|
||||
pub reminder_time: Option<String>,
|
||||
pub enabled: bool,
|
||||
#[serde(skip)]
|
||||
pub private_title: Option<String>,
|
||||
#[serde(skip)]
|
||||
pub private_notes: Option<String>,
|
||||
#[serde(skip)]
|
||||
pub decryption_failed: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
@@ -39,8 +56,10 @@ pub enum Schedule {
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct CreateTask {
|
||||
pub title: String,
|
||||
pub notes: Option<String>,
|
||||
pub public_title: String,
|
||||
pub encrypted_payload: Option<String>,
|
||||
pub encryption_version: Option<i16>,
|
||||
pub content_id: Option<String>,
|
||||
pub section: String,
|
||||
pub priority: String,
|
||||
pub scheduled_date: String,
|
||||
@@ -49,8 +68,10 @@ pub struct CreateTask {
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct CreateRoutine {
|
||||
pub title: String,
|
||||
pub notes: Option<String>,
|
||||
pub public_title: String,
|
||||
pub encrypted_payload: Option<String>,
|
||||
pub encryption_version: Option<i16>,
|
||||
pub content_id: Option<String>,
|
||||
pub section: String,
|
||||
pub priority: String,
|
||||
pub schedule: Schedule,
|
||||
@@ -62,6 +83,43 @@ pub struct RescheduleTask {
|
||||
pub scheduled_date: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct PrivatePayload {
|
||||
pub version: u8,
|
||||
pub content_id: String,
|
||||
#[serde(default)]
|
||||
pub private_title: Option<String>,
|
||||
#[serde(default)]
|
||||
pub notes: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct EncryptedFields {
|
||||
pub encrypted_payload: Option<String>,
|
||||
pub encryption_version: Option<i16>,
|
||||
pub content_id: Option<String>,
|
||||
}
|
||||
|
||||
impl Task {
|
||||
pub fn visible_title(&self) -> &str {
|
||||
self.private_title.as_deref().unwrap_or(&self.public_title)
|
||||
}
|
||||
|
||||
pub fn visible_notes(&self) -> Option<&str> {
|
||||
self.private_notes.as_deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl Routine {
|
||||
pub fn visible_title(&self) -> &str {
|
||||
self.private_title.as_deref().unwrap_or(&self.public_title)
|
||||
}
|
||||
|
||||
pub fn visible_notes(&self) -> Option<&str> {
|
||||
self.private_notes.as_deref()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn schedule_label(schedule: &Schedule) -> String {
|
||||
match schedule {
|
||||
Schedule::Daily => "daily".to_owned(),
|
||||
|
||||
Reference in New Issue
Block a user