From ccc0c2954bdc6111c5cf3f26cbbcd13c6f986a9c Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Thu, 18 Jul 2024 10:59:29 +0300
Subject: [PATCH] refactor: Use `pagination` directly as an argument
Signed-off-by: Awiteb
---
crates/oxidetalis/src/routes/user.rs | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/crates/oxidetalis/src/routes/user.rs b/crates/oxidetalis/src/routes/user.rs
index 7a0f423..9f3b777 100644
--- a/crates/oxidetalis/src/routes/user.rs
+++ b/crates/oxidetalis/src/routes/user.rs
@@ -22,7 +22,6 @@ use salvo::{
oapi::{endpoint, extract::JsonBody},
writing::Json,
Depot,
- Extractible,
Request,
Router,
Writer,
@@ -88,13 +87,13 @@ pub async fn register(
tags("User"),
responses(
(status_code = 200, description = "Returns whitelisted users", content_type = "application/json", body = Vec),
- (status_code = 403, description = "Not registered user, must register first", content_type = "application/json", body = MessageSchema),
+ (status_code = 400, description = "Wrong query parameter", content_type = "application/json", body = MessageSchema),
(status_code = 401, description = "The entered signature or public key is invalid", content_type = "application/json", body = MessageSchema),
+ (status_code = 403, description = "Not registered user, must register first", content_type = "application/json", body = MessageSchema),
(status_code = 429, description = "Too many requests", content_type = "application/json", body = MessageSchema),
(status_code = 500, description = "Internal server error", content_type = "application/json", body = MessageSchema),
),
parameters(
- Pagination,
("X-OTMP-PUBLIC" = PublicKey, Header, description = "Public key of the sender"),
("X-OTMP-SIGNATURE" = Signature, Header, description = "Signature of the request"),
),
@@ -102,8 +101,8 @@ pub async fn register(
async fn user_whitelist(
req: &mut Request,
depot: &mut Depot,
+ pagination: Pagination,
) -> ApiResult>> {
- let pagination = Pagination::extract(req).await?;
let conn = depot.db_conn();
let user = conn
.get_user_by_pubk(
@@ -127,13 +126,13 @@ async fn user_whitelist(
tags("User"),
responses(
(status_code = 200, description = "Returns blacklisted users", content_type = "application/json", body = Vec),
- (status_code = 403, description = "Not registered user, must register first", content_type = "application/json", body = MessageSchema),
+ (status_code = 400, description = "Wrong query parameter", content_type = "application/json", body = MessageSchema),
(status_code = 401, description = "The entered signature or public key is invalid", content_type = "application/json", body = MessageSchema),
+ (status_code = 403, description = "Not registered user, must register first", content_type = "application/json", body = MessageSchema),
(status_code = 429, description = "Too many requests", content_type = "application/json", body = MessageSchema),
(status_code = 500, description = "Internal server error", content_type = "application/json", body = MessageSchema),
),
parameters(
- Pagination,
("X-OTMP-PUBLIC" = PublicKey, Header, description = "Public key of the sender"),
("X-OTMP-SIGNATURE" = Signature, Header, description = "Signature of the request"),
),
@@ -141,8 +140,8 @@ async fn user_whitelist(
async fn user_blacklist(
req: &mut Request,
depot: &mut Depot,
+ pagination: Pagination,
) -> ApiResult>> {
- let pagination = Pagination::extract(req).await?;
let conn = depot.db_conn();
let user = conn
.get_user_by_pubk(