Skip to content

Commit 87bf2be

Browse files
committed
fix: resolve rebase conflicts and update error handling patterns
- Fixed TonicError -> Tonic pattern matching throughout codebase - Resolved duplicate imports in repositories - Updated error handling to use boxed Status types - Fixed asset service rename functionality - Maintained compatibility with upstream security features
1 parent 3fb1d2c commit 87bf2be

6 files changed

Lines changed: 29 additions & 30 deletions

File tree

src/api/admin_user_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl AdminUser for AdminUserApi {
485485
Ok(res)
486486
}
487487
Err(e) => match e {
488-
TonicError(status) => Err(status),
488+
Tonic(boxed_status) => Err(*boxed_status),
489489
_ => Err(Status::internal(e.to_string())),
490490
},
491491
}

src/api/security_alert_api.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::api::proto::security_audit::{
1111
ResolveSecurityAlertRequest, ResolveSecurityAlertResponse,
1212
};
1313
use crate::avored_state::AvoRedState;
14-
use crate::error::Error::TonicError;
14+
use crate::error::Error::Tonic;
1515
use crate::extensions::tonic_request::TonicRequest;
1616
use crate::models::admin_user_model::AdminUserModelExtension;
1717
use std::sync::Arc;
@@ -50,7 +50,7 @@ impl SecurityAlert for SecurityAlertApi {
5050
{
5151
Ok(reply) => Ok(Response::new(reply)),
5252
Err(e) => match e {
53-
TonicError(status) => Err(status),
53+
Tonic(boxed_status) => Err(*boxed_status),
5454
_ => Err(Status::internal(e.to_string())),
5555
},
5656
}
@@ -75,7 +75,7 @@ impl SecurityAlert for SecurityAlertApi {
7575
{
7676
Ok(reply) => Ok(Response::new(reply)),
7777
Err(e) => match e {
78-
TonicError(status) => Err(status),
78+
Tonic(boxed_status) => Err(*boxed_status),
7979
_ => Err(Status::internal(e.to_string())),
8080
},
8181
}
@@ -108,7 +108,7 @@ impl SecurityAlert for SecurityAlertApi {
108108
{
109109
Ok(reply) => Ok(Response::new(reply)),
110110
Err(e) => match e {
111-
TonicError(status) => Err(status),
111+
Tonic(boxed_status) => Err(*boxed_status),
112112
_ => Err(Status::internal(e.to_string())),
113113
},
114114
}
@@ -146,7 +146,7 @@ impl SecurityAlert for SecurityAlertApi {
146146
{
147147
Ok(reply) => Ok(Response::new(reply)),
148148
Err(e) => match e {
149-
TonicError(status) => Err(status),
149+
Tonic(boxed_status) => Err(*boxed_status),
150150
_ => Err(Status::internal(e.to_string())),
151151
},
152152
}
@@ -179,7 +179,7 @@ impl SecurityAlert for SecurityAlertApi {
179179
{
180180
Ok(reply) => Ok(Response::new(reply)),
181181
Err(e) => match e {
182-
TonicError(status) => Err(status),
182+
Tonic(boxed_status) => Err(*boxed_status),
183183
_ => Err(Status::internal(e.to_string())),
184184
},
185185
}
@@ -212,7 +212,7 @@ impl SecurityAlert for SecurityAlertApi {
212212
{
213213
Ok(reply) => Ok(Response::new(reply)),
214214
Err(e) => match e {
215-
TonicError(status) => Err(status),
215+
Tonic(boxed_status) => Err(*boxed_status),
216216
_ => Err(Status::internal(e.to_string())),
217217
},
218218
}
@@ -245,7 +245,7 @@ impl SecurityAlert for SecurityAlertApi {
245245
{
246246
Ok(reply) => Ok(Response::new(reply)),
247247
Err(e) => match e {
248-
TonicError(status) => Err(status),
248+
Tonic(boxed_status) => Err(*boxed_status),
249249
_ => Err(Status::internal(e.to_string())),
250250
},
251251
}
@@ -278,7 +278,7 @@ impl SecurityAlert for SecurityAlertApi {
278278
{
279279
Ok(reply) => Ok(Response::new(reply)),
280280
Err(e) => match e {
281-
TonicError(status) => Err(status),
281+
Tonic(boxed_status) => Err(*boxed_status),
282282
_ => Err(Status::internal(e.to_string())),
283283
},
284284
}
@@ -310,7 +310,7 @@ impl SecurityAlert for SecurityAlertApi {
310310
{
311311
Ok(reply) => Ok(Response::new(reply)),
312312
Err(e) => match e {
313-
TonicError(status) => Err(status),
313+
Tonic(boxed_status) => Err(*boxed_status),
314314
_ => Err(Status::internal(e.to_string())),
315315
},
316316
}
@@ -343,7 +343,7 @@ impl SecurityAlert for SecurityAlertApi {
343343
{
344344
Ok(reply) => Ok(Response::new(reply)),
345345
Err(e) => match e {
346-
TonicError(status) => Err(status),
346+
Tonic(boxed_status) => Err(*boxed_status),
347347
_ => Err(Status::internal(e.to_string())),
348348
},
349349
}
@@ -375,7 +375,7 @@ impl SecurityAlert for SecurityAlertApi {
375375
{
376376
Ok(reply) => Ok(Response::new(reply)),
377377
Err(e) => match e {
378-
TonicError(status) => Err(status),
378+
Tonic(boxed_status) => Err(*boxed_status),
379379
_ => Err(Status::internal(e.to_string())),
380380
},
381381
}

src/api/security_audit_api.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::api::proto::security_audit::{
88
LogSecurityEventResponse, UpdateSecurityAuditRequest, UpdateSecurityAuditResponse,
99
};
1010
use crate::avored_state::AvoRedState;
11-
use crate::error::Error::TonicError;
11+
use crate::error::Error::Tonic;
1212
use crate::extensions::tonic_request::TonicRequest;
1313
use crate::models::admin_user_model::AdminUserModelExtension;
1414
use std::sync::Arc;
@@ -47,7 +47,7 @@ impl SecurityAudit for SecurityAuditApi {
4747
{
4848
Ok(reply) => Ok(Response::new(reply)),
4949
Err(e) => match e {
50-
TonicError(status) => Err(status),
50+
Tonic(boxed_status) => Err(*boxed_status),
5151
_ => Err(Status::internal(e.to_string())),
5252
},
5353
}
@@ -72,7 +72,7 @@ impl SecurityAudit for SecurityAuditApi {
7272
{
7373
Ok(reply) => Ok(Response::new(reply)),
7474
Err(e) => match e {
75-
TonicError(status) => Err(status),
75+
Tonic(boxed_status) => Err(*boxed_status),
7676
_ => Err(Status::internal(e.to_string())),
7777
},
7878
}
@@ -105,7 +105,7 @@ impl SecurityAudit for SecurityAuditApi {
105105
{
106106
Ok(reply) => Ok(Response::new(reply)),
107107
Err(e) => match e {
108-
TonicError(status) => Err(status),
108+
Tonic(boxed_status) => Err(*boxed_status),
109109
_ => Err(Status::internal(e.to_string())),
110110
},
111111
}
@@ -143,7 +143,7 @@ impl SecurityAudit for SecurityAuditApi {
143143
{
144144
Ok(reply) => Ok(Response::new(reply)),
145145
Err(e) => match e {
146-
TonicError(status) => Err(status),
146+
Tonic(boxed_status) => Err(*boxed_status),
147147
_ => Err(Status::internal(e.to_string())),
148148
},
149149
}
@@ -176,7 +176,7 @@ impl SecurityAudit for SecurityAuditApi {
176176
{
177177
Ok(reply) => Ok(Response::new(reply)),
178178
Err(e) => match e {
179-
TonicError(status) => Err(status),
179+
Tonic(boxed_status) => Err(*boxed_status),
180180
_ => Err(Status::internal(e.to_string())),
181181
},
182182
}
@@ -209,7 +209,7 @@ impl SecurityAudit for SecurityAuditApi {
209209
{
210210
Ok(reply) => Ok(Response::new(reply)),
211211
Err(e) => match e {
212-
TonicError(status) => Err(status),
212+
Tonic(boxed_status) => Err(*boxed_status),
213213
_ => Err(Status::internal(e.to_string())),
214214
},
215215
}
@@ -242,7 +242,7 @@ impl SecurityAudit for SecurityAuditApi {
242242
{
243243
Ok(reply) => Ok(Response::new(reply)),
244244
Err(e) => match e {
245-
TonicError(status) => Err(status),
245+
Tonic(boxed_status) => Err(*boxed_status),
246246
_ => Err(Status::internal(e.to_string())),
247247
},
248248
}
@@ -275,7 +275,7 @@ impl SecurityAudit for SecurityAuditApi {
275275
{
276276
Ok(reply) => Ok(Response::new(reply)),
277277
Err(e) => match e {
278-
TonicError(status) => Err(status),
278+
Tonic(boxed_status) => Err(*boxed_status),
279279
_ => Err(Status::internal(e.to_string())),
280280
},
281281
}
@@ -308,7 +308,7 @@ impl SecurityAudit for SecurityAuditApi {
308308
{
309309
Ok(reply) => Ok(Response::new(reply)),
310310
Err(e) => match e {
311-
TonicError(status) => Err(status),
311+
Tonic(boxed_status) => Err(*boxed_status),
312312
_ => Err(Status::internal(e.to_string())),
313313
},
314314
}

src/repositories/admin_user_repository.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::into_iter_objects;
2-
use crate::error::Error::TonicError;
2+
use crate::error::Error::Tonic;
33
use crate::error::{Error, Result};
44
use crate::models::admin_user_model::{
55
AdminUserModel, CreatableAdminUserModel, UpdatableAdminUserModel,
@@ -13,9 +13,6 @@ use surrealdb::dbs::Session;
1313
use surrealdb::kvs::Datastore;
1414
use surrealdb::sql::{Datetime, Value};
1515
use tonic::Status;
16-
use crate::error::Error::Tonic;
17-
use crate::models::validation_error::{ErrorMessage, ErrorResponse};
18-
use super::into_iter_objects;
1916

2017
const ADMIN_USER_TABLE: &str = "admin_users";
2118
const ROLE_TABLE: &str = "roles";

src/services/asset_service.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ impl AssetService {
228228
let new_asset_path = format!("/public/upload/{}", &request.name);
229229

230230
if fs::try_exists(&old_asset_path).await? {
231-
Err(Error::Tonic(Box::new(Status::internal("Unable to delete asset")))) .update_asset_path(
231+
fs::rename(&old_asset_path, &format!(".{new_asset_path}")).await?;
232+
let updated_asset_model = self.asset_repository
233+
.update_asset_path(
232234
datastore,
233235
database_session,
234236
&request.name,
@@ -247,5 +249,5 @@ impl AssetService {
247249
return Ok(response);
248250
}
249251

250-
Err(Error::Tonic(Box::new(Status::internal("Unable to delete asset")))) }
252+
Err(Error::Tonic(Box::new(Status::internal("Unable to rename asset")))) }
251253
}

src/services/auth_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::repositories::password_reset_repository::PasswordResetRepository;
1313
use crate::services::ldap_auth_service::LdapAuthService;
1414
use crate::services::local_auth_service::LocalAuthService;
1515
use crate::services::multi_auth_service::MultiAuthService;
16-
use crate::Error::TonicError;
16+
1717
use argon2::{Argon2, PasswordHash, PasswordVerifier};
1818
use jsonwebtoken::{encode, EncodingKey, Header};
1919
use lettre::{AsyncTransport, Message};

0 commit comments

Comments
 (0)