]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/custom_emoji.rs
Automatically resolve report when post/comment is removed (#3850)
[lemmy.git] / crates / db_schema / src / source / custom_emoji.rs
1 use crate::newtypes::{CustomEmojiId, DbUrl, LocalSiteId};
2 #[cfg(feature = "full")]
3 use crate::schema::custom_emoji;
4 use serde::{Deserialize, Serialize};
5 use serde_with::skip_serializing_none;
6 #[cfg(feature = "full")]
7 use ts_rs::TS;
8 use typed_builder::TypedBuilder;
9
10 #[skip_serializing_none]
11 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
12 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable, TS))]
13 #[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
14 #[cfg_attr(
15   feature = "full",
16   diesel(belongs_to(crate::source::local_site::LocalSite))
17 )]
18 #[cfg_attr(feature = "full", ts(export))]
19 /// A custom emoji.
20 pub struct CustomEmoji {
21   pub id: CustomEmojiId,
22   pub local_site_id: LocalSiteId,
23   pub shortcode: String,
24   pub image_url: DbUrl,
25   pub alt_text: String,
26   pub category: String,
27   pub published: chrono::NaiveDateTime,
28   pub updated: Option<chrono::NaiveDateTime>,
29 }
30
31 #[derive(Debug, Clone, TypedBuilder)]
32 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
33 #[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
34 pub struct CustomEmojiInsertForm {
35   pub local_site_id: LocalSiteId,
36   pub shortcode: String,
37   pub image_url: DbUrl,
38   pub alt_text: String,
39   pub category: String,
40 }
41
42 #[derive(Debug, Clone, TypedBuilder)]
43 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
44 #[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
45 pub struct CustomEmojiUpdateForm {
46   pub local_site_id: LocalSiteId,
47   pub image_url: DbUrl,
48   pub alt_text: String,
49   pub category: String,
50 }