2022-05-03 17:44:13 +00:00
|
|
|
use crate::newtypes::{DbUrl, PersonId, PrivateMessageId};
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use crate::schema::private_message;
|
2022-11-02 19:18:22 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
use serde_with::skip_serializing_none;
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2022-11-02 19:18:22 +00:00
|
|
|
use typed_builder::TypedBuilder;
|
2022-05-03 17:44:13 +00:00
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable, TS))]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
diesel(belongs_to(crate::source::person::Person, foreign_key = creator_id)
|
|
|
|
))] // Is this the right assoc?
|
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = private_message))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2020-12-21 13:38:34 +00:00
|
|
|
pub struct PrivateMessage {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub id: PrivateMessageId,
|
|
|
|
pub creator_id: PersonId,
|
|
|
|
pub recipient_id: PersonId,
|
2020-12-21 13:38:34 +00:00
|
|
|
pub content: String,
|
|
|
|
pub deleted: bool,
|
|
|
|
pub read: bool,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
2021-03-02 12:41:48 +00:00
|
|
|
pub ap_id: DbUrl,
|
2020-12-21 13:38:34 +00:00
|
|
|
pub local: bool,
|
|
|
|
}
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
#[derive(Clone, TypedBuilder)]
|
|
|
|
#[builder(field_defaults(default))]
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = private_message))]
|
2022-10-27 09:24:07 +00:00
|
|
|
pub struct PrivateMessageInsertForm {
|
|
|
|
#[builder(!default)]
|
2021-03-18 20:25:21 +00:00
|
|
|
pub creator_id: PersonId,
|
2022-10-27 09:24:07 +00:00
|
|
|
#[builder(!default)]
|
2021-03-18 20:25:21 +00:00
|
|
|
pub recipient_id: PersonId,
|
2022-10-27 09:24:07 +00:00
|
|
|
#[builder(!default)]
|
2020-12-21 13:38:34 +00:00
|
|
|
pub content: String,
|
|
|
|
pub deleted: Option<bool>,
|
|
|
|
pub read: Option<bool>,
|
|
|
|
pub published: Option<chrono::NaiveDateTime>,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
2021-03-02 12:41:48 +00:00
|
|
|
pub ap_id: Option<DbUrl>,
|
2021-03-20 20:59:07 +00:00
|
|
|
pub local: Option<bool>,
|
2020-12-21 13:38:34 +00:00
|
|
|
}
|
2022-10-27 09:24:07 +00:00
|
|
|
|
|
|
|
#[derive(Clone, TypedBuilder)]
|
|
|
|
#[builder(field_defaults(default))]
|
|
|
|
#[cfg_attr(feature = "full", derive(AsChangeset))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = private_message))]
|
|
|
|
pub struct PrivateMessageUpdateForm {
|
|
|
|
pub content: Option<String>,
|
|
|
|
pub deleted: Option<bool>,
|
|
|
|
pub read: Option<bool>,
|
|
|
|
pub published: Option<chrono::NaiveDateTime>,
|
|
|
|
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
|
|
|
pub ap_id: Option<DbUrl>,
|
|
|
|
pub local: Option<bool>,
|
|
|
|
}
|