]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_site_rate_limit.rs
Automatically resolve report when post/comment is removed (#3850)
[lemmy.git] / crates / db_schema / src / source / local_site_rate_limit.rs
1 use crate::newtypes::LocalSiteId;
2 #[cfg(feature = "full")]
3 use crate::schema::local_site_rate_limit;
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, Identifiable, TS))]
13 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
14 #[cfg_attr(
15   feature = "full",
16   diesel(belongs_to(crate::source::local_site::LocalSite))
17 )]
18 #[cfg_attr(feature = "full", ts(export))]
19 /// Rate limits for your site. Given in count / length of time.
20 pub struct LocalSiteRateLimit {
21   pub id: i32,
22   pub local_site_id: LocalSiteId,
23   pub message: i32,
24   pub message_per_second: i32,
25   pub post: i32,
26   pub post_per_second: i32,
27   pub register: i32,
28   pub register_per_second: i32,
29   pub image: i32,
30   pub image_per_second: i32,
31   pub comment: i32,
32   pub comment_per_second: i32,
33   pub search: i32,
34   pub search_per_second: i32,
35   pub published: chrono::NaiveDateTime,
36   pub updated: Option<chrono::NaiveDateTime>,
37 }
38
39 #[derive(Clone, TypedBuilder)]
40 #[builder(field_defaults(default))]
41 #[cfg_attr(feature = "full", derive(Insertable))]
42 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
43 pub struct LocalSiteRateLimitInsertForm {
44   #[builder(!default)]
45   pub local_site_id: LocalSiteId,
46   pub message: Option<i32>,
47   pub message_per_second: Option<i32>,
48   pub post: Option<i32>,
49   pub post_per_second: Option<i32>,
50   pub register: Option<i32>,
51   pub register_per_second: Option<i32>,
52   pub image: Option<i32>,
53   pub image_per_second: Option<i32>,
54   pub comment: Option<i32>,
55   pub comment_per_second: Option<i32>,
56   pub search: Option<i32>,
57   pub search_per_second: Option<i32>,
58 }
59
60 #[derive(Clone, Default)]
61 #[cfg_attr(feature = "full", derive(AsChangeset))]
62 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
63 pub struct LocalSiteRateLimitUpdateForm {
64   pub message: Option<i32>,
65   pub message_per_second: Option<i32>,
66   pub post: Option<i32>,
67   pub post_per_second: Option<i32>,
68   pub register: Option<i32>,
69   pub register_per_second: Option<i32>,
70   pub image: Option<i32>,
71   pub image_per_second: Option<i32>,
72   pub comment: Option<i32>,
73   pub comment_per_second: Option<i32>,
74   pub search: Option<i32>,
75   pub search_per_second: Option<i32>,
76   pub updated: Option<Option<chrono::NaiveDateTime>>,
77 }