2023-10-02 07:12:24 +00:00
|
|
|
use collab_define::reminder::{ObjectType, Reminder, ReminderMeta};
|
2023-08-14 04:57:59 +00:00
|
|
|
use flowy_derive::ProtoBuf;
|
2023-10-02 07:12:24 +00:00
|
|
|
use std::collections::HashMap;
|
2023-08-14 04:57:59 +00:00
|
|
|
|
|
|
|
#[derive(ProtoBuf, Default, Clone)]
|
|
|
|
pub struct ReminderPB {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub id: String,
|
|
|
|
|
|
|
|
#[pb(index = 2)]
|
2023-10-02 07:12:24 +00:00
|
|
|
pub object_id: String,
|
2023-08-14 04:57:59 +00:00
|
|
|
|
|
|
|
#[pb(index = 3)]
|
2023-10-02 07:12:24 +00:00
|
|
|
pub scheduled_at: i64,
|
2023-08-14 04:57:59 +00:00
|
|
|
|
|
|
|
#[pb(index = 4)]
|
2023-10-02 07:12:24 +00:00
|
|
|
pub is_ack: bool,
|
2023-08-14 04:57:59 +00:00
|
|
|
|
|
|
|
#[pb(index = 5)]
|
2023-10-02 07:12:24 +00:00
|
|
|
pub is_read: bool,
|
2023-08-14 04:57:59 +00:00
|
|
|
|
|
|
|
#[pb(index = 6)]
|
2023-10-02 07:12:24 +00:00
|
|
|
pub title: String,
|
2023-08-14 04:57:59 +00:00
|
|
|
|
|
|
|
#[pb(index = 7)]
|
2023-10-02 07:12:24 +00:00
|
|
|
pub message: String,
|
|
|
|
|
|
|
|
#[pb(index = 8)]
|
|
|
|
pub meta: HashMap<String, String>,
|
2023-08-14 04:57:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(ProtoBuf, Default, Clone)]
|
|
|
|
pub struct RepeatedReminderPB {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub items: Vec<ReminderPB>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<ReminderPB> for Reminder {
|
|
|
|
fn from(value: ReminderPB) -> Self {
|
|
|
|
Self {
|
|
|
|
id: value.id,
|
|
|
|
scheduled_at: value.scheduled_at,
|
|
|
|
is_ack: value.is_ack,
|
2023-10-02 07:12:24 +00:00
|
|
|
is_read: value.is_read,
|
2023-09-01 14:40:17 +00:00
|
|
|
ty: ObjectType::Document,
|
2023-08-14 04:57:59 +00:00
|
|
|
title: value.title,
|
|
|
|
message: value.message,
|
2023-10-02 07:12:24 +00:00
|
|
|
meta: ReminderMeta::from(value.meta),
|
|
|
|
object_id: value.object_id,
|
2023-08-14 04:57:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Reminder> for ReminderPB {
|
|
|
|
fn from(value: Reminder) -> Self {
|
|
|
|
Self {
|
|
|
|
id: value.id,
|
2023-10-02 07:12:24 +00:00
|
|
|
object_id: value.object_id,
|
2023-08-14 04:57:59 +00:00
|
|
|
scheduled_at: value.scheduled_at,
|
|
|
|
is_ack: value.is_ack,
|
2023-10-02 07:12:24 +00:00
|
|
|
is_read: value.is_read,
|
2023-08-14 04:57:59 +00:00
|
|
|
title: value.title,
|
|
|
|
message: value.message,
|
2023-10-02 07:12:24 +00:00
|
|
|
meta: value.meta.into_inner(),
|
2023-08-14 04:57:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Vec<ReminderPB>> for RepeatedReminderPB {
|
|
|
|
fn from(value: Vec<ReminderPB>) -> Self {
|
|
|
|
Self { items: value }
|
|
|
|
}
|
|
|
|
}
|
2023-10-02 07:12:24 +00:00
|
|
|
|
|
|
|
#[derive(ProtoBuf, Default, Clone)]
|
|
|
|
pub struct ReminderIdentifierPB {
|
|
|
|
#[pb(index = 1)]
|
|
|
|
pub id: String,
|
|
|
|
}
|