summaryrefslogtreecommitdiffstats
path: root/server/src/api/comment.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/api/comment.rs')
-rw-r--r--server/src/api/comment.rs60
1 files changed, 15 insertions, 45 deletions
diff --git a/server/src/api/comment.rs b/server/src/api/comment.rs
index 8e398c9a..058c7267 100644
--- a/server/src/api/comment.rs
+++ b/server/src/api/comment.rs
@@ -59,12 +59,13 @@ pub struct GetCommentsResponse {
comments: Vec<CommentView>,
}
-impl Perform<CommentResponse> for Oper<CreateComment> {
+impl Perform for Oper<CreateComment> {
+ type Response = CommentResponse;
+
fn perform(
&self,
pool: Pool<ConnectionManager<PgConnection>>,
websocket_info: Option<WebsocketInfo>,
- rate_limit_info: Option<RateLimitInfo>,
) -> Result<CommentResponse, Error> {
let data: &CreateComment = &self.data;
@@ -77,13 +78,6 @@ impl Perform<CommentResponse> for Oper<CreateComment> {
let hostname = &format!("https://{}", Settings::get().hostname);
- if let Some(rl) = rate_limit_info {
- rl.rate_limiter
- .lock()
- .unwrap()
- .check_rate_limit_message(&rl.ip, false)?;
- }
-
let conn = pool.get()?;
// Check for a community ban
@@ -253,12 +247,13 @@ impl Perform<CommentResponse> for Oper<CreateComment> {
}
}
-impl Perform<CommentResponse> for Oper<EditComment> {
+impl Perform for Oper<EditComment> {
+ type Response = CommentResponse;
+
fn perform(
&self,
pool: Pool<ConnectionManager<PgConnection>>,
websocket_info: Option<WebsocketInfo>,
- rate_limit_info: Option<RateLimitInfo>,
) -> Result<CommentResponse, Error> {
let data: &EditComment = &self.data;
@@ -269,13 +264,6 @@ impl Perform<CommentResponse> for Oper<EditComment> {
let user_id = claims.id;
- if let Some(rl) = rate_limit_info {
- rl.rate_limiter
- .lock()
- .unwrap()
- .check_rate_limit_message(&rl.ip, false)?;
- }
-
let conn = pool.get()?;
let orig_comment = CommentView::read(&conn, data.edit_id, None)?;
@@ -411,12 +399,13 @@ impl Perform<CommentResponse> for Oper<EditComment> {
}
}
-impl Perform<CommentResponse> for Oper<SaveComment> {
+impl Perform for Oper<SaveComment> {
+ type Response = CommentResponse;
+
fn perform(
&self,
pool: Pool<ConnectionManager<PgConnection>>,
_websocket_info: Option<WebsocketInfo>,
- rate_limit_info: Option<RateLimitInfo>,
) -> Result<CommentResponse, Error> {
let data: &SaveComment = &self.data;
@@ -432,13 +421,6 @@ impl Perform<CommentResponse> for Oper<SaveComment> {
user_id,
};
- if let Some(rl) = rate_limit_info {
- rl.rate_limiter
- .lock()
- .unwrap()
- .check_rate_limit_message(&rl.ip, false)?;
- }
-
let conn = pool.get()?;
if data.save {
@@ -462,12 +444,13 @@ impl Perform<CommentResponse> for Oper<SaveComment> {
}
}
-impl Perform<CommentResponse> for Oper<CreateCommentLike> {
+impl Perform for Oper<CreateCommentLike> {
+ type Response = CommentResponse;
+
fn perform(
&self,
pool: Pool<ConnectionManager<PgConnection>>,
websocket_info: Option<WebsocketInfo>,
- rate_limit_info: Option<RateLimitInfo>,
) -> Result<CommentResponse, Error> {
let data: &CreateCommentLike = &self.data;
@@ -480,13 +463,6 @@ impl Perform<CommentResponse> for Oper<CreateCommentLike> {
let mut recipient_ids = Vec::new();
- if let Some(rl) = rate_limit_info {
- rl.rate_limiter
- .lock()
- .unwrap()
- .check_rate_limit_message(&rl.ip, false)?;
- }
-
let conn = pool.get()?;
// Don't do a downvote if site has downvotes disabled
@@ -567,12 +543,13 @@ impl Perform<CommentResponse> for Oper<CreateCommentLike> {
}
}
-impl Perform<GetCommentsResponse> for Oper<GetComments> {
+impl Perform for Oper<GetComments> {
+ type Response = GetCommentsResponse;
+
fn perform(
&self,
pool: Pool<ConnectionManager<PgConnection>>,
websocket_info: Option<WebsocketInfo>,
- rate_limit_info: Option<RateLimitInfo>,
) -> Result<GetCommentsResponse, Error> {
let data: &GetComments = &self.data;
@@ -592,13 +569,6 @@ impl Perform<GetCommentsResponse> for Oper<GetComments> {
let type_ = ListingType::from_str(&data.type_)?;
let sort = SortType::from_str(&data.sort)?;
- if let Some(rl) = rate_limit_info {
- rl.rate_limiter
- .lock()
- .unwrap()
- .check_rate_limit_message(&rl.ip, false)?;
- }
-
let conn = pool.get()?;
let comments = match CommentQueryBuilder::create(&conn)