]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_site_rate_limit.rs
Moving settings to Database. (#2492)
[lemmy.git] / crates / db_schema / src / source / local_site_rate_limit.rs
1 use crate::newtypes::LocalSiteId;
2 use serde::{Deserialize, Serialize};
3 use typed_builder::TypedBuilder;
4
5 #[cfg(feature = "full")]
6 use crate::schema::local_site_rate_limit;
7
8 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
9 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
10 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
11 #[cfg_attr(
12   feature = "full",
13   diesel(belongs_to(crate::source::local_site::LocalSite))
14 )]
15 pub struct LocalSiteRateLimit {
16   pub id: i32,
17   pub local_site_id: LocalSiteId,
18   pub message: i32,
19   pub message_per_second: i32,
20   pub post: i32,
21   pub post_per_second: i32,
22   pub register: i32,
23   pub register_per_second: i32,
24   pub image: i32,
25   pub image_per_second: i32,
26   pub comment: i32,
27   pub comment_per_second: i32,
28   pub search: i32,
29   pub search_per_second: i32,
30   pub published: chrono::NaiveDateTime,
31   pub updated: Option<chrono::NaiveDateTime>,
32 }
33
34 #[derive(Clone, TypedBuilder)]
35 #[builder(field_defaults(default))]
36 #[cfg_attr(feature = "full", derive(Insertable))]
37 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
38 pub struct LocalSiteRateLimitInsertForm {
39   #[builder(!default)]
40   pub local_site_id: LocalSiteId,
41   pub message: Option<i32>,
42   pub message_per_second: Option<i32>,
43   pub post: Option<i32>,
44   pub post_per_second: Option<i32>,
45   pub register: Option<i32>,
46   pub register_per_second: Option<i32>,
47   pub image: Option<i32>,
48   pub image_per_second: Option<i32>,
49   pub comment: Option<i32>,
50   pub comment_per_second: Option<i32>,
51   pub search: Option<i32>,
52   pub search_per_second: Option<i32>,
53 }
54
55 #[derive(Clone, TypedBuilder)]
56 #[builder(field_defaults(default))]
57 #[cfg_attr(feature = "full", derive(AsChangeset))]
58 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
59 pub struct LocalSiteRateLimitUpdateForm {
60   pub message: Option<i32>,
61   pub message_per_second: Option<i32>,
62   pub post: Option<i32>,
63   pub post_per_second: Option<i32>,
64   pub register: Option<i32>,
65   pub register_per_second: Option<i32>,
66   pub image: Option<i32>,
67   pub image_per_second: Option<i32>,
68   pub comment: Option<i32>,
69   pub comment_per_second: Option<i32>,
70   pub search: Option<i32>,
71   pub search_per_second: Option<i32>,
72   pub updated: Option<Option<chrono::NaiveDateTime>>,
73 }