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")]
8 use typed_builder::TypedBuilder;
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))]
16 diesel(belongs_to(crate::source::local_site::LocalSite))
18 #[cfg_attr(feature = "full", ts(export))]
19 /// Rate limits for your site. Given in count / length of time.
20 pub struct LocalSiteRateLimit {
22 pub local_site_id: LocalSiteId,
24 pub message_per_second: i32,
26 pub post_per_second: i32,
28 pub register_per_second: i32,
30 pub image_per_second: i32,
32 pub comment_per_second: i32,
34 pub search_per_second: i32,
35 pub published: chrono::NaiveDateTime,
36 pub updated: Option<chrono::NaiveDateTime>,
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 {
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>,
60 #[derive(Clone, TypedBuilder)]
61 #[builder(field_defaults(default))]
62 #[cfg_attr(feature = "full", derive(AsChangeset))]
63 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
64 pub struct LocalSiteRateLimitUpdateForm {
65 pub message: Option<i32>,
66 pub message_per_second: Option<i32>,
67 pub post: Option<i32>,
68 pub post_per_second: Option<i32>,
69 pub register: Option<i32>,
70 pub register_per_second: Option<i32>,
71 pub image: Option<i32>,
72 pub image_per_second: Option<i32>,
73 pub comment: Option<i32>,
74 pub comment_per_second: Option<i32>,
75 pub search: Option<i32>,
76 pub search_per_second: Option<i32>,
77 pub updated: Option<Option<chrono::NaiveDateTime>>,