]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/actor_language.rs
implement language tags for site/community in db and api (#2434)
[lemmy.git] / crates / db_schema / src / source / actor_language.rs
1 use crate::newtypes::{
2   CommunityId,
3   CommunityLanguageId,
4   LanguageId,
5   LocalUserId,
6   LocalUserLanguageId,
7   SiteId,
8   SiteLanguageId,
9 };
10 use serde::{Deserialize, Serialize};
11
12 #[cfg(feature = "full")]
13 use crate::schema::local_user_language;
14
15 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
16 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
17 #[cfg_attr(feature = "full", diesel(table_name = local_user_language))]
18 pub struct LocalUserLanguage {
19   #[serde(skip)]
20   pub id: LocalUserLanguageId,
21   pub local_user_id: LocalUserId,
22   pub language_id: LanguageId,
23 }
24
25 #[derive(Clone)]
26 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
27 #[cfg_attr(feature = "full", diesel(table_name = local_user_language))]
28 pub struct LocalUserLanguageForm {
29   pub local_user_id: LocalUserId,
30   pub language_id: LanguageId,
31 }
32
33 #[cfg(feature = "full")]
34 use crate::schema::community_language;
35
36 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
37 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
38 #[cfg_attr(feature = "full", diesel(table_name = community_language))]
39 pub struct CommunityLanguage {
40   #[serde(skip)]
41   pub id: CommunityLanguageId,
42   pub community_id: CommunityId,
43   pub language_id: LanguageId,
44 }
45
46 #[derive(Clone)]
47 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
48 #[cfg_attr(feature = "full", diesel(table_name = community_language))]
49 pub struct CommunityLanguageForm {
50   pub community_id: CommunityId,
51   pub language_id: LanguageId,
52 }
53
54 #[cfg(feature = "full")]
55 use crate::schema::site_language;
56
57 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
58 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
59 #[cfg_attr(feature = "full", diesel(table_name = site_language))]
60 pub struct SiteLanguage {
61   #[serde(skip)]
62   pub id: SiteLanguageId,
63   pub site_id: SiteId,
64   pub language_id: LanguageId,
65 }
66
67 #[derive(Clone, Debug)]
68 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
69 #[cfg_attr(feature = "full", diesel(table_name = site_language))]
70 pub struct SiteLanguageForm {
71   pub site_id: SiteId,
72   pub language_id: LanguageId,
73 }