]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/custom_emoji.rs
Add Custom Emojis Support (#2616)
[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 typed_builder::TypedBuilder;
6
7 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
9 #[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
10 #[cfg_attr(
11   feature = "full",
12   diesel(belongs_to(crate::source::local_site::LocalSite))
13 )]
14 pub struct CustomEmoji {
15   pub id: CustomEmojiId,
16   pub local_site_id: LocalSiteId,
17   pub shortcode: String,
18   pub image_url: DbUrl,
19   pub alt_text: String,
20   pub category: String,
21   pub published: chrono::NaiveDateTime,
22   pub updated: Option<chrono::NaiveDateTime>,
23 }
24
25 #[derive(Debug, Clone, TypedBuilder)]
26 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
27 #[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
28 pub struct CustomEmojiInsertForm {
29   pub local_site_id: LocalSiteId,
30   pub shortcode: String,
31   pub image_url: DbUrl,
32   pub alt_text: String,
33   pub category: String,
34 }
35
36 #[derive(Debug, Clone, TypedBuilder)]
37 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
38 #[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
39 pub struct CustomEmojiUpdateForm {
40   pub local_site_id: LocalSiteId,
41   pub image_url: DbUrl,
42   pub alt_text: String,
43   pub category: String,
44 }