style: format code for improved readability and consistency across multiple files
ZhenYi committed
Modified lib/auth/src/handlers/accept_agreement.rs lib/auth/src/handlers/accept_agreement.rs +4 −3 View lib/auth/src/handlers/accept_agreement.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::{Path, State};
2use axum::Json;
33
4use export::rest::{AppResponseData};use serde::{Deserialize, Serialize};
4use export::rest::AppResponseData;
5use serde::{Deserialize, Serialize};
56use session::Session;
67use utoipa::ToSchema;
78
@@ -34,7 +35,7 @@
3435 Json(cmd): Json<AcceptAgreementCmd>,
3536) -> Result<AppResponseData<AcceptAgreementResp>, ApiError> {
3637 let uid = require_uid(&session)?;
37 let resp = service
38 let resp = service
3839 .accept_agreement(uid, &key, &cmd.version)
3940 .await
4041 .map_err(ApiError::from)?;
Modified lib/auth/src/handlers/add_ssh_key.rs lib/auth/src/handlers/add_ssh_key.rs +3 −2 View lib/auth/src/handlers/add_ssh_key.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/change_password.rs lib/auth/src/handlers/change_password.rs +3 −2 View lib/auth/src/handlers/change_password.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData, NoData};use session::Session;
4use export::rest::{AppResponseData, NoData};
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/confirm_email_change.rs lib/auth/src/handlers/confirm_email_change.rs +4 −3 View lib/auth/src/handlers/confirm_email_change.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData, NoData};use serde::{Deserialize, Serialize};
4use export::rest::{AppResponseData, NoData};
5use serde::{Deserialize, Serialize};
56use session::Session;
67use utoipa::ToSchema;
78use uuid::Uuid;
@@ -31,7 +32,7 @@
3132 Json(cmd): Json<ConfirmEmailChangeCmd>,
3233) -> Result<AppResponseData<NoData>, ApiError> {
3334 let uid = require_uid(&session)?;
34 service
35 service
3536 .confirm_email_change(uid, cmd.ticket_id, &cmd.code)
3637 .await
3738 .map_err(ApiError::from)?;
Modified lib/auth/src/handlers/create_access_key.rs lib/auth/src/handlers/create_access_key.rs +3 −2 View lib/auth/src/handlers/create_access_key.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/create_report.rs lib/auth/src/handlers/create_report.rs +3 −2 View lib/auth/src/handlers/create_report.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/forgot_password.rs lib/auth/src/handlers/forgot_password.rs +3 −2 View lib/auth/src/handlers/forgot_password.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/login.rs lib/auth/src/handlers/login.rs +4 −6 View lib/auth/src/handlers/login.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
@@ -21,9 +22,6 @@
2122 session: Session,
2223 Json(cmd): Json<LoginCmd>,
2324) -> Result<AppResponseData<LoginResp>, ApiError> {
24 let resp = service
25 .login(&session, cmd)
26 .await
27 .map_err(ApiError::from)?;
25 let resp = service.login(&session, cmd).await.map_err(ApiError::from)?;
2826 Ok(AppResponseData::ok(resp))
2927}
Modified lib/auth/src/handlers/login_2fa.rs lib/auth/src/handlers/login_2fa.rs +3 −2 View lib/auth/src/handlers/login_2fa.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/reclaim.rs lib/auth/src/handlers/reclaim.rs +3 −2 View lib/auth/src/handlers/reclaim.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/regenerate_recovery_codes.rs lib/auth/src/handlers/regenerate_recovery_codes.rs +3 −2 View lib/auth/src/handlers/regenerate_recovery_codes.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/register.rs lib/auth/src/handlers/register.rs +3 −2 View lib/auth/src/handlers/register.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/request_deletion.rs lib/auth/src/handlers/request_deletion.rs +4 −3 View lib/auth/src/handlers/request_deletion.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use serde::{Deserialize, Serialize};
4use export::rest::AppResponseData;
5use serde::{Deserialize, Serialize};
56use session::Session;
67use utoipa::ToSchema;
78
@@ -30,7 +31,7 @@
3031 Json(cmd): Json<RequestDeletionCmd>,
3132) -> Result<AppResponseData<DeletionDto>, ApiError> {
3233 let uid = require_uid(&session)?;
33 let resp = service
34 let resp = service
3435 .request_deletion(uid, cmd.reason)
3536 .await
3637 .map_err(ApiError::from)?;
Modified lib/auth/src/handlers/request_email_change.rs lib/auth/src/handlers/request_email_change.rs +3 −2 View lib/auth/src/handlers/request_email_change.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/resend_code.rs lib/auth/src/handlers/resend_code.rs +3 −2 View lib/auth/src/handlers/resend_code.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/reset_password.rs lib/auth/src/handlers/reset_password.rs +3 −6 View lib/auth/src/handlers/reset_password.rs
@@ -1,10 +1,10 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData, NoData};
54use crate::errors::ApiError;
65use crate::services::AuthService;
76use crate::services::password::ResetPasswordCmd;
7use export::rest::{AppResponseData, NoData};
88
99#[utoipa::path(
1010 post,
@@ -19,9 +19,6 @@
1919 State(service): State<AuthService>,
2020 Json(cmd): Json<ResetPasswordCmd>,
2121) -> Result<AppResponseData<NoData>, ApiError> {
22 service
23 .reset_password(cmd)
24 .await
25 .map_err(ApiError::from)?;
22 service.reset_password(cmd).await.map_err(ApiError::from)?;
2623 Ok(AppResponseData::empty())
2724}
Modified lib/auth/src/handlers/totp_disable.rs lib/auth/src/handlers/totp_disable.rs +3 −2 View lib/auth/src/handlers/totp_disable.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData, NoData};use session::Session;
4use export::rest::{AppResponseData, NoData};
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/totp_enable.rs lib/auth/src/handlers/totp_enable.rs +3 −2 View lib/auth/src/handlers/totp_enable.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};use session::Session;
4use export::rest::AppResponseData;
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/update_preferences.rs lib/auth/src/handlers/update_preferences.rs +3 −2 View lib/auth/src/handlers/update_preferences.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData, NoData};use session::Session;
4use export::rest::{AppResponseData, NoData};
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/update_profile.rs lib/auth/src/handlers/update_profile.rs +3 −2 View lib/auth/src/handlers/update_profile.rs
@@ -1,7 +1,8 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData, NoData};use session::Session;
4use export::rest::{AppResponseData, NoData};
5use session::Session;
56
67use crate::errors::ApiError;
78use crate::services::AuthService;
Modified lib/auth/src/handlers/verify_email.rs lib/auth/src/handlers/verify_email.rs +2 −2 View lib/auth/src/handlers/verify_email.rs
@@ -1,10 +1,10 @@
1use axum::Json;
12use axum::extract::State;
2use axum::Json;
33
4use export::rest::{AppResponseData};
54use crate::errors::ApiError;
65use crate::services::AuthService;
76use crate::services::email::{VerifyEmailCmd, VerifyEmailResp};
7use export::rest::AppResponseData;
88
99#[utoipa::path(
1010 post,
Modified lib/auth/src/errors.rs lib/auth/src/errors.rs +21 −7 View lib/auth/src/errors.rs
@@ -150,16 +150,30 @@
150150impl From<AuthError> for ApiError {
151151 fn from(error: AuthError) -> Self {
152152 match error {
153 AuthError::BadRequest(msg) => Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request")),
154 AuthError::PowFailed => Self::BadRequest(Self::payload(400, "proof of work failed").with_error_code("pow_failed")),
153 AuthError::BadRequest(msg) => {
154 Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request"))
155 }
156 AuthError::PowFailed => Self::BadRequest(
157 Self::payload(400, "proof of work failed").with_error_code("pow_failed"),
158 ),
155159 AuthError::InvalidCredentials => {
156160 Self::InvalidCredentials(Self::payload(400, "invalid credentials"))
157161 }
158 AuthError::Unauthorized => Self::Unauthorized(Self::payload(401, "unauthorized").with_error_code("unauthorized")),
159 AuthError::Forbidden => Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden")),
160 AuthError::NotFound => Self::NotFound(Self::payload(404, "auth resource not found").with_error_code("not_found")),
161 AuthError::Conflict(msg) => Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict")),
162 AuthError::RateLimited => Self::RateLimited(Self::payload(429, "rate limit exceeded").with_error_code("rate_limited")),
162 AuthError::Unauthorized => Self::Unauthorized(
163 Self::payload(401, "unauthorized").with_error_code("unauthorized"),
164 ),
165 AuthError::Forbidden => {
166 Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden"))
167 }
168 AuthError::NotFound => Self::NotFound(
169 Self::payload(404, "auth resource not found").with_error_code("not_found"),
170 ),
171 AuthError::Conflict(msg) => {
172 Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict"))
173 }
174 AuthError::RateLimited => Self::RateLimited(
175 Self::payload(429, "rate limit exceeded").with_error_code("rate_limited"),
176 ),
163177 AuthError::Internal(message) => {
164178 tracing::warn!(error = %message, "auth handler failed");
165179 Self::Internal(Self::payload(500, "internal server error"))
Modified lib/chat/src/services/rooms.rs lib/chat/src/services/rooms.rs +5 −1 View lib/chat/src/services/rooms.rs
@@ -620,7 +620,11 @@
620620 .filter(room_members::Column::LeftAt.is_null())
621621 .order_by_asc(room_members::Column::JoinedAt)
622622 .limit(limit)
623 .offset(q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET))
623 .offset(
624 q.offset
625 .unwrap_or(0)
626 .clamp(0, export::pagination::MAX_OFFSET),
627 )
624628 .all(self.db().read())
625629 .await?;
626630 let uids: Vec<Uuid> = rows.iter().map(|r| r.user_id).collect();
Modified lib/chat/src/services/search.rs lib/chat/src/services/search.rs +4 −1 View lib/chat/src/services/search.rs
@@ -66,7 +66,10 @@
6666 .limit
6767 .unwrap_or(self.config().chat.default_pagination)
6868 .clamp(1, self.config().chat.max_pagination);
69 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
69 let offset = q
70 .offset
71 .unwrap_or(0)
72 .clamp(0, export::pagination::MAX_OFFSET);
7073
7174 // Private rooms must be restricted to their members; public space
7275 // rooms are readable by every space member.
Modified lib/chat/src/services/threads.rs lib/chat/src/services/threads.rs +4 −1 View lib/chat/src/services/threads.rs
@@ -257,7 +257,10 @@
257257 .limit
258258 .unwrap_or(self.config().chat.default_pagination)
259259 .clamp(1, self.config().chat.max_pagination);
260 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
260 let offset = q
261 .offset
262 .unwrap_or(0)
263 .clamp(0, export::pagination::MAX_OFFSET);
261264
262265 let mut select = threads::Entity::find().filter(threads::Column::RoomId.eq(room_id));
263266 if let Some(archived) = q.archived {
Modified lib/chat/src/ws/ticket.rs lib/chat/src/ws/ticket.rs +1 −5 View lib/chat/src/ws/ticket.rs
@@ -80,11 +80,7 @@
8080
8181/// Marks a ticket as consumed exactly once. Returns false when the ticket
8282/// was already used (replay) or redis failed.
83pub async fn consume_ticket(
84 redis: &export::AppRedis,
85 jti: Uuid,
86 ttl_secs: i64,
87) -> bool {
83pub async fn consume_ticket(redis: &export::AppRedis, jti: Uuid, ttl_secs: i64) -> bool {
8884 use export::RedisConnection;
8985 let mut conn = redis.connection_clone();
9086 let result: Result<Option<String>, redis::RedisError> = match &mut conn {
Modified lib/chat/src/errors.rs lib/chat/src/errors.rs +18 −6 View lib/chat/src/errors.rs
@@ -162,12 +162,24 @@
162162impl From<ChatError> for ApiError {
163163 fn from(error: ChatError) -> Self {
164164 match error {
165 ChatError::BadRequest(msg) => Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request")),
166 ChatError::Unauthorized => Self::Unauthorized(Self::payload(401, "unauthorized").with_error_code("unauthorized")),
167 ChatError::Forbidden => Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden")),
168 ChatError::NotFound => Self::NotFound(Self::payload(404, "chat resource not found").with_error_code("not_found")),
169 ChatError::Conflict(msg) => Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict")),
170 ChatError::RateLimited(msg) => Self::TooManyRequests(AppResponseData::err(429, msg).with_error_code("rate_limited")),
165 ChatError::BadRequest(msg) => {
166 Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request"))
167 }
168 ChatError::Unauthorized => Self::Unauthorized(
169 Self::payload(401, "unauthorized").with_error_code("unauthorized"),
170 ),
171 ChatError::Forbidden => {
172 Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden"))
173 }
174 ChatError::NotFound => Self::NotFound(
175 Self::payload(404, "chat resource not found").with_error_code("not_found"),
176 ),
177 ChatError::Conflict(msg) => {
178 Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict"))
179 }
180 ChatError::RateLimited(msg) => Self::TooManyRequests(
181 AppResponseData::err(429, msg).with_error_code("rate_limited"),
182 ),
171183 ChatError::Internal(message) => {
172184 tracing::warn!(error = %message, "chat handler failed");
173185 Self::Internal(Self::payload(500, "internal server error"))
Modified lib/chat/src/routes.rs lib/chat/src/routes.rs +4 −1 View lib/chat/src/routes.rs
@@ -36,7 +36,10 @@
3636use crate::share::guard::chat_guard;
3737use crate::ws::ws_upgrade;
3838
39pub fn router(service: ChatService, space_service: space::services::service::SpaceService) -> Router<ChatService> {
39pub fn router(
40 service: ChatService,
41 space_service: space::services::service::SpaceService,
42) -> Router<ChatService> {
4043 let space_room_routes = Router::new()
4144 .route(
4245 "/chat/spaces/{space_name}/rooms",
Modified lib/config/src/lib.rs lib/config/src/lib.rs +1 −1 View lib/config/src/lib.rs
@@ -9,10 +9,10 @@
99pub mod githost;
1010pub mod issues;
1111pub mod pow;
12pub mod quota;
1213pub mod redis;
1314pub mod s3;
1415pub mod session;
15pub mod quota;
1616pub mod space;
1717pub mod user;
1818pub mod web;
Modified lib/config/src/session.rs lib/config/src/session.rs +2 −1 View lib/config/src/session.rs
@@ -47,7 +47,8 @@
4747 pub fn is_valid(&self) -> Result<(), String> {
4848 if self.cookie_same_site == Some(SameSite::None) && self.cookie_secure != Some(true) {
4949 return Err(
50 "session.cookie_same_site = \"none\" requires session.cookie_secure = true".to_string(),
50 "session.cookie_same_site = \"none\" requires session.cookie_secure = true"
51 .to_string(),
5152 );
5253 }
5354 if self.cookie_prefix_host == Some(true)
Modified lib/export/src/lib.rs lib/export/src/lib.rs +1 −1 View lib/export/src/lib.rs
@@ -1,6 +1,6 @@
11pub mod database;
2pub mod error;
23pub mod health;
3pub mod error;
44pub mod middleware;
55pub mod pagination;
66pub mod redis;
Modified lib/export/src/middleware.rs lib/export/src/middleware.rs +5 −3 View lib/export/src/middleware.rs
@@ -57,8 +57,7 @@
5757 }
5858
5959 fn call(&mut self, mut req: Request<Body>) -> Self::Future {
60 let request_id =
61 inbound_id(req.headers().get(&REQUEST_ID_HEADER)).unwrap_or_else(new_id);
60 let request_id = inbound_id(req.headers().get(&REQUEST_ID_HEADER)).unwrap_or_else(new_id);
6261 let log_id = new_id();
6362
6463 req.extensions_mut().insert(RequestId(request_id.clone()));
@@ -114,7 +113,10 @@
114113 Ok(Value::Object(mut map))
115114 if map.contains_key("request_id") && map.contains_key("log_id") =>
116115 {
117 map.insert("request_id".to_string(), Value::String(request_id.to_string()));
116 map.insert(
117 "request_id".to_string(),
118 Value::String(request_id.to_string()),
119 );
118120 map.insert("log_id".to_string(), Value::String(log_id.to_string()));
119121 match serde_json::to_vec(&map) {
120122 Ok(rewritten) => Bytes::from(rewritten),
Modified lib/export/src/pagination.rs lib/export/src/pagination.rs +3 −1 View lib/export/src/pagination.rs
@@ -13,7 +13,9 @@
1313
1414impl PageQuery {
1515 pub fn limit(&self) -> u64 {
16 self.limit.unwrap_or(DEFAULT_PAGE_LIMIT).clamp(1, MAX_PAGE_LIMIT)
16 self.limit
17 .unwrap_or(DEFAULT_PAGE_LIMIT)
18 .clamp(1, MAX_PAGE_LIMIT)
1719 }
1820
1921 pub fn offset(&self) -> u64 {
Modified lib/export/src/redis.rs lib/export/src/redis.rs +10 −4 View lib/export/src/redis.rs
@@ -151,8 +151,11 @@
151151 .await
152152 .unwrap_or(0);
153153 if count == 1 {
154 let _: Result<redis::Value, redis::RedisError> =
155 redis::cmd("EXPIRE").arg(key).arg(window_secs).query_async(c).await;
154 let _: Result<redis::Value, redis::RedisError> = redis::cmd("EXPIRE")
155 .arg(key)
156 .arg(window_secs)
157 .query_async(c)
158 .await;
156159 }
157160 Ok(count)
158161 }
@@ -163,8 +166,11 @@
163166 .await
164167 .unwrap_or(0);
165168 if count == 1 {
166 let _: Result<redis::Value, redis::RedisError> =
167 redis::cmd("EXPIRE").arg(key).arg(window_secs).query_async(c).await;
169 let _: Result<redis::Value, redis::RedisError> = redis::cmd("EXPIRE")
170 .arg(key)
171 .arg(window_secs)
172 .query_async(c)
173 .await;
168174 }
169175 Ok(count)
170176 }
Modified lib/export/src/rest.rs lib/export/src/rest.rs +0 −1 View lib/export/src/rest.rs
@@ -19,7 +19,6 @@
1919 pub log_id: String,
2020}
2121
22
2322impl<T> AppResponseData<T>
2423where
2524 T: Serialize,
Modified lib/git/src/handler/licenses.rs lib/git/src/handler/licenses.rs +8 −2 View lib/git/src/handler/licenses.rs
@@ -32,8 +32,14 @@
3232 State(service): State<GitService>,
3333 Query(q): Query<LicenseListQuery>,
3434) -> Result<AppResponseData<Vec<LicenseDto>>, ApiError> {
35 let limit = q.limit.unwrap_or(export::pagination::DEFAULT_PAGE_LIMIT).clamp(1, export::pagination::MAX_PAGE_LIMIT);
36 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
35 let limit = q
36 .limit
37 .unwrap_or(export::pagination::DEFAULT_PAGE_LIMIT)
38 .clamp(1, export::pagination::MAX_PAGE_LIMIT);
39 let offset = q
40 .offset
41 .unwrap_or(0)
42 .clamp(0, export::pagination::MAX_OFFSET);
3743 let out = service
3844 .list_licenses(limit, offset)
3945 .await
Modified lib/git/src/handler/stars.rs lib/git/src/handler/stars.rs +4 −1 View lib/git/src/handler/stars.rs
@@ -133,7 +133,10 @@
133133 )
134134 .await?;
135135 let limit = q.limit.unwrap_or(50).clamp(1, 100);
136 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
136 let offset = q
137 .offset
138 .unwrap_or(0)
139 .clamp(0, export::pagination::MAX_OFFSET);
137140 let out = service
138141 .list_stargazers(&ctx, limit, offset)
139142 .await
Modified lib/git/src/handler/topics.rs lib/git/src/handler/topics.rs +8 −2 View lib/git/src/handler/topics.rs
@@ -67,7 +67,10 @@
6767 Query(q): Query<TopicListQuery>,
6868) -> Result<AppResponseData<Vec<TopicDto>>, ApiError> {
6969 let limit = q.limit.unwrap_or(50).clamp(1, 100);
70 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
70 let offset = q
71 .offset
72 .unwrap_or(0)
73 .clamp(0, export::pagination::MAX_OFFSET);
7174 let out = service
7275 .list_topics(limit, offset)
7376 .await
@@ -110,7 +113,10 @@
110113 Query(q): Query<TopicListQuery>,
111114) -> Result<AppResponseData<Vec<TopicRepoDto>>, ApiError> {
112115 let limit = q.limit.unwrap_or(50).clamp(1, 100);
113 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
116 let offset = q
117 .offset
118 .unwrap_or(0)
119 .clamp(0, export::pagination::MAX_OFFSET);
114120 let out = service
115121 .list_repos_by_topic(&p.name, limit, offset)
116122 .await
Modified lib/git/src/handler/watches.rs lib/git/src/handler/watches.rs +4 −2 View lib/git/src/handler/watches.rs
@@ -133,11 +133,13 @@
133133 )
134134 .await?;
135135 let limit = q.limit.unwrap_or(50).clamp(1, 100);
136 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
136 let offset = q
137 .offset
138 .unwrap_or(0)
139 .clamp(0, export::pagination::MAX_OFFSET);
137140 let out = service
138141 .list_watchers(&ctx, q.mode, limit, offset)
139142 .await
140143 .map_err(GitApiError::from)?;
141144 Ok(AppResponseData::ok(out))
142145}
143
Modified lib/git/src/handler/whitelists.rs lib/git/src/handler/whitelists.rs +42 −19 View lib/git/src/handler/whitelists.rs
@@ -60,9 +60,13 @@
6060 Path(p): Path<BranchPolicyPath>,
6161 Json(cmd): Json<AddBranchWhitelistCmd>,
6262) -> Result<AppResponseData<BranchWhitelistDto>, ApiError> {
63 let (ctx, _) =
64 require_repo_admin(&service, &session, p.space_name.clone(), p.repo_name.clone())
65 .await?;
63 let (ctx, _) = require_repo_admin(
64 &service,
65 &session,
66 p.space_name.clone(),
67 p.repo_name.clone(),
68 )
69 .await?;
6670 let out = service
6771 .add_branch_whitelist(ctx.model.id, p.policy_id, cmd)
6872 .await
@@ -84,9 +88,13 @@
8488 session: Session,
8589 Path(p): Path<BranchWhitelistPath>,
8690) -> Result<AppResponseData<NoData>, ApiError> {
87 let (ctx, _) =
88 require_repo_admin(&service, &session, p.space_name.clone(), p.repo_name.clone())
89 .await?;
91 let (ctx, _) = require_repo_admin(
92 &service,
93 &session,
94 p.space_name.clone(),
95 p.repo_name.clone(),
96 )
97 .await?;
9098 service
9199 .remove_branch_whitelist(ctx.model.id, p.policy_id, p.whitelist_id)
92100 .await
@@ -108,9 +116,13 @@
108116 session: Session,
109117 Path(p): Path<BranchPolicyPath>,
110118) -> Result<AppResponseData<Vec<BranchWhitelistDto>>, ApiError> {
111 let (ctx, _) =
112 require_repo_admin(&service, &session, p.space_name.clone(), p.repo_name.clone())
113 .await?;
119 let (ctx, _) = require_repo_admin(
120 &service,
121 &session,
122 p.space_name.clone(),
123 p.repo_name.clone(),
124 )
125 .await?;
114126 let out = service
115127 .list_branch_whitelists(ctx.model.id, p.policy_id)
116128 .await
@@ -134,9 +146,13 @@
134146 Path(p): Path<TagPolicyPath>,
135147 Json(cmd): Json<AddTagWhitelistCmd>,
136148) -> Result<AppResponseData<TagWhitelistDto>, ApiError> {
137 let (ctx, _) =
138 require_repo_admin(&service, &session, p.space_name.clone(), p.repo_name.clone())
139 .await?;
149 let (ctx, _) = require_repo_admin(
150 &service,
151 &session,
152 p.space_name.clone(),
153 p.repo_name.clone(),
154 )
155 .await?;
140156 let out = service
141157 .add_tag_whitelist(ctx.model.id, p.policy_id, cmd)
142158 .await
@@ -158,9 +174,13 @@
158174 session: Session,
159175 Path(p): Path<TagWhitelistPath>,
160176) -> Result<AppResponseData<NoData>, ApiError> {
161 let (ctx, _) =
162 require_repo_admin(&service, &session, p.space_name.clone(), p.repo_name.clone())
163 .await?;
177 let (ctx, _) = require_repo_admin(
178 &service,
179 &session,
180 p.space_name.clone(),
181 p.repo_name.clone(),
182 )
183 .await?;
164184 service
165185 .remove_tag_whitelist(ctx.model.id, p.policy_id, p.user_id)
166186 .await
@@ -182,13 +202,16 @@
182202 session: Session,
183203 Path(p): Path<TagPolicyPath>,
184204) -> Result<AppResponseData<Vec<TagWhitelistDto>>, ApiError> {
185 let (ctx, _) =
186 require_repo_admin(&service, &session, p.space_name.clone(), p.repo_name.clone())
187 .await?;
205 let (ctx, _) = require_repo_admin(
206 &service,
207 &session,
208 p.space_name.clone(),
209 p.repo_name.clone(),
210 )
211 .await?;
188212 let out = service
189213 .list_tag_whitelists(ctx.model.id, p.policy_id)
190214 .await
191215 .map_err(GitApiError::from)?;
192216 Ok(AppResponseData::ok(out))
193217}
194
Modified lib/git/src/routes.rs lib/git/src/routes.rs +5 −20 View lib/git/src/routes.rs
@@ -286,11 +286,8 @@
286286 "/{space_name}/{repo_name}/lfs/locks",
287287 get(list_locks).post(lock),
288288 )
289 .route("/{space_name}/{repo_name}/lfs/locks/unlock", post(unlock))
289290 .route(
290 "/{space_name}/{repo_name}/lfs/locks/unlock",
291 post(unlock),
292 )
293 .route(
294291 "/{space_name}/{repo_name}/lfs/locks/verify",
295292 post(verify_locks),
296293 )
@@ -394,30 +391,18 @@
394391 "/{space_name}/{repo_name}/commits/{revision}/sync",
395392 post(sync_commit),
396393 )
397 .route(
398 "/{space_name}/{repo_name}/patch/apply",
399 post(patch_apply),
400 )
394 .route("/{space_name}/{repo_name}/patch/apply", post(patch_apply))
401395 .route("/_/pipelines/cancel", post(cancel))
402396 .route("/{space_name}/{repo_name}/packs/stats", get(pack_stats))
403397 .route("/{space_name}/{repo_name}/packs/ingest", post(pack_ingest))
404398 .route("/{space_name}/{repo_name}/packs/repack", post(pack_repack))
399 .route("/{space_name}/{repo_name}/maintenance/prune", post(prune))
400 .route("/{space_name}/{repo_name}/maintenance/fsck", post(fsck))
405401 .route(
406 "/{space_name}/{repo_name}/maintenance/prune",
407 post(prune),
408 )
409 .route(
410 "/{space_name}/{repo_name}/maintenance/fsck",
411 post(fsck),
412 )
413 .route(
414402 "/{space_name}/{repo_name}/lfs/cleanup",
415403 post(cleanup_unreferenced),
416404 )
417 .route(
418 "/{space_name}/{repo_name}/contents/blobs",
419 post(write_blob),
420 )
405 .route("/{space_name}/{repo_name}/contents/blobs", post(write_blob))
421406 .route(
422407 "/{space_name}/{repo_name}/contents/trees",
423408 post(write_tree_from_files),
Modified lib/issues/src/handlers/reactions/remove_reaction.rs lib/issues/src/handlers/reactions/remove_reaction.rs +7 −1 View lib/issues/src/handlers/reactions/remove_reaction.rs
@@ -27,7 +27,13 @@
2727) -> Result<AppResponseData<NoData>, ApiError> {
2828 let uid = require_uid(&session)?;
2929 service
30 .remove_reaction_by_emoji(uid, &path.space_name, path.board_id, path.issue_id, &q.emoji)
30 .remove_reaction_by_emoji(
31 uid,
32 &path.space_name,
33 path.board_id,
34 path.issue_id,
35 &q.emoji,
36 )
3137 .await?;
3238 Ok(AppResponseData::ok(NoData))
3339}
Modified lib/issues/src/services/boards.rs lib/issues/src/services/boards.rs +5 −1 View lib/issues/src/services/boards.rs
@@ -75,7 +75,11 @@
7575}
7676
7777impl IssueService {
78 fn board_dto(board: issues::Model, open_issues_count: i64, closed_issues_count: i64) -> BoardDto {
78 fn board_dto(
79 board: issues::Model,
80 open_issues_count: i64,
81 closed_issues_count: i64,
82 ) -> BoardDto {
7983 BoardDto {
8084 id: board.id,
8185 dir_id: board.dir_id,
Modified lib/issues/src/errors.rs lib/issues/src/errors.rs +17 −7 View lib/issues/src/errors.rs
@@ -144,14 +144,24 @@
144144impl From<IssueError> for ApiError {
145145 fn from(error: IssueError) -> Self {
146146 match error {
147 IssueError::BadRequest(msg) => Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request")),
148 IssueError::Unauthorized => Self::Unauthorized(Self::payload(401, "unauthorized").with_error_code("unauthorized")),
149 IssueError::Forbidden => Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden")),
150 IssueError::NotFound => Self::NotFound(Self::payload(404, "issue resource not found").with_error_code("not_found")),
151 IssueError::Conflict(msg) => Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict")),
152 IssueError::RateLimited(msg) => {
153 Self::TooManyRequests(AppResponseData::err(429, msg).with_error_code("rate_limited"))
147 IssueError::BadRequest(msg) => {
148 Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request"))
149 }
150 IssueError::Unauthorized => Self::Unauthorized(
151 Self::payload(401, "unauthorized").with_error_code("unauthorized"),
152 ),
153 IssueError::Forbidden => {
154 Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden"))
155 }
156 IssueError::NotFound => Self::NotFound(
157 Self::payload(404, "issue resource not found").with_error_code("not_found"),
158 ),
159 IssueError::Conflict(msg) => {
160 Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict"))
154161 }
162 IssueError::RateLimited(msg) => Self::TooManyRequests(
163 AppResponseData::err(429, msg).with_error_code("rate_limited"),
164 ),
155165 IssueError::Internal(message) => {
156166 tracing::warn!(error = %message, "issues handler failed");
157167 Self::Internal(Self::payload(500, "internal server error"))
Modified lib/issues/src/routes.rs lib/issues/src/routes.rs +2 −2 View lib/issues/src/routes.rs
@@ -46,10 +46,10 @@
4646use crate::handlers::pins::list_pins::list_pins;
4747use crate::handlers::reactions::add_comment_reaction::add_comment_reaction;
4848use crate::handlers::reactions::add_reaction::add_reaction;
49use crate::handlers::reactions::list_comment_reactions::list_comment_reactions;
50use crate::handlers::reactions::list_reactions::list_reactions;
4951use crate::handlers::reactions::remove_comment_reaction::remove_comment_reaction;
5052use crate::handlers::reactions::remove_reaction::remove_reaction;
51use crate::handlers::reactions::list_comment_reactions::list_comment_reactions;
52use crate::handlers::reactions::list_reactions::list_reactions;
5353use crate::handlers::repo_relations::create_repo_relation::create_repo_relation;
5454use crate::handlers::repo_relations::delete_repo_relation::delete_repo_relation;
5555use crate::handlers::repo_relations::list_repo_relations::list_repo_relations;
Modified lib/space/src/handlers/get_ban.rs lib/space/src/handlers/get_ban.rs +3 −1 View lib/space/src/handlers/get_ban.rs
@@ -25,6 +25,8 @@
2525 Path(path): Path<MemberPath>,
2626) -> Result<AppResponseData<BanDto>, ApiError> {
2727 let caller = require_uid(&session)?;
28 let ban = service.get_ban(caller, &path.space_name, path.user_id).await?;
28 let ban = service
29 .get_ban(caller, &path.space_name, path.user_id)
30 .await?;
2931 Ok(AppResponseData::ok(ban))
3032}
Modified lib/space/src/handlers/get_member.rs lib/space/src/handlers/get_member.rs +3 −1 View lib/space/src/handlers/get_member.rs
@@ -33,6 +33,8 @@
3333 Path(path): Path<MemberPath>,
3434) -> Result<AppResponseData<MemberDto>, ApiError> {
3535 let uid = require_uid(&session)?;
36 let member = service.get_member(uid, &path.space_name, path.user_id).await?;
36 let member = service
37 .get_member(uid, &path.space_name, path.user_id)
38 .await?;
3739 Ok(AppResponseData::ok(member))
3840}
Modified lib/space/src/services/bans.rs lib/space/src/services/bans.rs +4 −1 View lib/space/src/services/bans.rs
@@ -296,7 +296,10 @@
296296 .limit
297297 .unwrap_or(default_pagination)
298298 .clamp(1, max_pagination);
299 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
299 let offset = q
300 .offset
301 .unwrap_or(0)
302 .clamp(0, export::pagination::MAX_OFFSET);
300303
301304 let select = space_bans::Entity::find()
302305 .filter(space_bans::Column::SpaceId.eq(space.id))
Modified lib/space/src/services/dir.rs lib/space/src/services/dir.rs +2 −2 View lib/space/src/services/dir.rs
@@ -7,8 +7,8 @@
77use models::space::space_member_groups;
88use models::users::user;
99use sea_orm::{
10 ActiveModelTrait, ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder,
11 Set, TransactionTrait,
10 ActiveModelTrait, ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder, Set,
11 TransactionTrait,
1212};
1313use serde::{Deserialize, Serialize};
1414use time::OffsetDateTime;
Modified lib/space/src/services/groups.rs lib/space/src/services/groups.rs +4 −1 View lib/space/src/services/groups.rs
@@ -397,7 +397,10 @@
397397 .limit
398398 .unwrap_or(default_pagination)
399399 .clamp(1, max_pagination);
400 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
400 let offset = q
401 .offset
402 .unwrap_or(0)
403 .clamp(0, export::pagination::MAX_OFFSET);
401404
402405 let select = space_groups::Entity::find()
403406 .filter(space_groups::Column::SpaceId.eq(space.id))
Modified lib/space/src/services/invites.rs lib/space/src/services/invites.rs +4 −1 View lib/space/src/services/invites.rs
@@ -530,7 +530,10 @@
530530 .limit
531531 .unwrap_or(default_pagination)
532532 .clamp(1, max_pagination);
533 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
533 let offset = q
534 .offset
535 .unwrap_or(0)
536 .clamp(0, export::pagination::MAX_OFFSET);
534537
535538 let select = space_invite::Entity::find()
536539 .filter(space_invite::Column::SpaceId.eq(space.id))
Modified lib/space/src/services/members.rs lib/space/src/services/members.rs +4 −1 View lib/space/src/services/members.rs
@@ -450,7 +450,10 @@
450450 .limit
451451 .unwrap_or(default_pagination)
452452 .clamp(1, max_pagination);
453 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
453 let offset = q
454 .offset
455 .unwrap_or(0)
456 .clamp(0, export::pagination::MAX_OFFSET);
454457
455458 let select = space_members::Entity::find()
456459 .filter(space_members::Column::SpaceId.eq(space.id))
Modified lib/space/src/services/rooms.rs lib/space/src/services/rooms.rs +1 −1 View lib/space/src/services/rooms.rs
@@ -1,7 +1,7 @@
11use models::room::room_members;
22use models::room::rooms::{self, RoomKind};
3use models::space::space_members::{self, MemberStatus};
34use models::space::spaces;
4use models::space::space_members::{self, MemberStatus};
55use sea_orm::{
66 ActiveModelTrait, ColumnTrait, EntityTrait, ExprTrait, QueryFilter, QuerySelect, Set,
77 TransactionTrait,
Modified lib/space/src/services/spaces.rs lib/space/src/services/spaces.rs +4 −1 View lib/space/src/services/spaces.rs
@@ -479,7 +479,10 @@
479479 .limit
480480 .unwrap_or(default_pagination)
481481 .clamp(1, max_pagination);
482 let offset = q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET);
482 let offset = q
483 .offset
484 .unwrap_or(0)
485 .clamp(0, export::pagination::MAX_OFFSET);
483486
484487 let select = spaces::Entity::find()
485488 .filter(spaces::Column::OwnerId.eq(caller))
Modified lib/space/src/errors.rs lib/space/src/errors.rs +18 −11 View lib/space/src/errors.rs
@@ -125,10 +125,7 @@
125125impl IntoResponse for ApiError {
126126 fn into_response(self) -> Response {
127127 let (code, envelope) = self.decompose();
128 let status = match StatusCode::from_u16(code) {
129 Ok(status) => status,
130 Err(_) => StatusCode::INTERNAL_SERVER_ERROR,
131 };
128 let status = StatusCode::from_u16(code).unwrap_or_else(|_| StatusCode::INTERNAL_SERVER_ERROR);
132129 (status, Json(envelope)).into_response()
133130 }
134131}
@@ -136,14 +133,24 @@
136133impl From<SpaceError> for ApiError {
137134 fn from(error: SpaceError) -> Self {
138135 match error {
139 SpaceError::BadRequest(msg) => Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request")),
140 SpaceError::Unauthorized => Self::Unauthorized(Self::payload(401, "unauthorized").with_error_code("unauthorized")),
141 SpaceError::Forbidden => Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden")),
142 SpaceError::NotFound => Self::NotFound(Self::payload(404, "space resource not found").with_error_code("not_found")),
143 SpaceError::Conflict(msg) => Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict")),
144 SpaceError::RateLimited(msg) => {
145 Self::TooManyRequests(AppResponseData::err(429, msg).with_error_code("rate_limited"))
136 SpaceError::BadRequest(msg) => {
137 Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request"))
146138 }
139 SpaceError::Unauthorized => Self::Unauthorized(
140 Self::payload(401, "unauthorized").with_error_code("unauthorized"),
141 ),
142 SpaceError::Forbidden => {
143 Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden"))
144 }
145 SpaceError::NotFound => Self::NotFound(
146 Self::payload(404, "space resource not found").with_error_code("not_found"),
147 ),
148 SpaceError::Conflict(msg) => {
149 Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict"))
150 }
151 SpaceError::RateLimited(msg) => Self::TooManyRequests(
152 AppResponseData::err(429, msg).with_error_code("rate_limited"),
153 ),
147154 SpaceError::Internal(message) => {
148155 tracing::warn!(error = %message, "space handler failed");
149156 Self::Internal(Self::payload(500, "internal server error"))
Modified lib/user/src/services/notifications.rs lib/user/src/services/notifications.rs +0 −3 View lib/user/src/services/notifications.rs
@@ -84,7 +84,6 @@
8484 pub message_id: Uuid,
8585}
8686
87
8887impl UserService {
8988 pub async fn recent_mentions(
9089 &self,
@@ -162,6 +161,4 @@
162161 .await?;
163162 Ok(())
164163 }
165
166
167164}
Modified lib/user/src/services/sessions.rs lib/user/src/services/sessions.rs +5 −1 View lib/user/src/services/sessions.rs
@@ -79,7 +79,11 @@
7979 .unwrap_or(DEFAULT_PAGE_LIMIT)
8080 .clamp(1, MAX_PAGE_LIMIT),
8181 )
82 .offset(q.offset.unwrap_or(0).clamp(0, export::pagination::MAX_OFFSET))
82 .offset(
83 q.offset
84 .unwrap_or(0)
85 .clamp(0, export::pagination::MAX_OFFSET),
86 )
8387 .all(self.db().read())
8488 .await?;
8589 Ok(rows.into_iter().map(SessionDto::from).collect())
Modified lib/user/src/share/page.rs lib/user/src/share/page.rs +1 −1 View lib/user/src/share/page.rs
@@ -1 +1 @@
1pub use export::pagination::{PageQuery, Page, DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT};
1pub use export::pagination::{DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT, Page, PageQuery};
Modified lib/user/src/share/types.rs lib/user/src/share/types.rs +0 −1 View lib/user/src/share/types.rs
@@ -1,2 +1 @@
1
21pub type ListQuery = export::pagination::PageQuery;
Modified lib/user/src/errors.rs lib/user/src/errors.rs +15 −5 View lib/user/src/errors.rs
@@ -137,11 +137,21 @@
137137impl From<UserError> for ApiError {
138138 fn from(error: UserError) -> Self {
139139 match error {
140 UserError::BadRequest(msg) => Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request")),
141 UserError::Unauthorized => Self::Unauthorized(Self::payload(401, "unauthorized").with_error_code("unauthorized")),
142 UserError::Forbidden => Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden")),
143 UserError::NotFound => Self::NotFound(Self::payload(404, "user resource not found").with_error_code("not_found")),
144 UserError::Conflict(msg) => Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict")),
140 UserError::BadRequest(msg) => {
141 Self::BadRequest(AppResponseData::err(400, msg).with_error_code("bad_request"))
142 }
143 UserError::Unauthorized => Self::Unauthorized(
144 Self::payload(401, "unauthorized").with_error_code("unauthorized"),
145 ),
146 UserError::Forbidden => {
147 Self::Forbidden(Self::payload(403, "forbidden").with_error_code("forbidden"))
148 }
149 UserError::NotFound => Self::NotFound(
150 Self::payload(404, "user resource not found").with_error_code("not_found"),
151 ),
152 UserError::Conflict(msg) => {
153 Self::Conflict(AppResponseData::err(409, msg).with_error_code("conflict"))
154 }
145155 UserError::Internal(message) => {
146156 tracing::warn!(error = %message, "user handler failed");
147157 Self::Internal(Self::payload(500, "internal server error"))
Modified lib/webapi/src/lib.rs lib/webapi/src/lib.rs +0 −1 View lib/webapi/src/lib.rs
@@ -9,7 +9,6 @@
99use tower_http::trace::{DefaultMakeSpan, DefaultOnRequest, DefaultOnResponse, TraceLayer};
1010use tracing::Level;
1111
12
1312const MAX_REQUEST_BODY_BYTES: usize = 2 * 1024 * 1024;
1413
1514fn build_cors_layer(web: &config::web::WebConfig) -> tower_http::cors::CorsLayer {
Modified lib/webapi/src/openapi.rs lib/webapi/src/openapi.rs +6 −2 View lib/webapi/src/openapi.rs
@@ -89,8 +89,12 @@
8989 doc.info.description = Some(CONVENTIONS.to_string());
9090 doc.info.license = None;
9191 {
92 use utoipa::openapi::security::{ApiKey, ApiKeyValue, Http, HttpAuthScheme, SecurityScheme};
93 let components = doc.components.get_or_insert_with(utoipa::openapi::Components::default);
92 use utoipa::openapi::security::{
93 ApiKey, ApiKeyValue, Http, HttpAuthScheme, SecurityScheme,
94 };
95 let components = doc
96 .components
97 .get_or_insert_with(utoipa::openapi::Components::default);
9498 components.add_security_scheme(
9599 "session_cookie",
96100 SecurityScheme::ApiKey(ApiKey::Cookie(ApiKeyValue::new("gitdata_session"))),