-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d10790f
commit 66b31e2
Showing
10 changed files
with
724 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use { | ||
crate::{ | ||
error::Error::{self}, | ||
handlers::validate_tenant_request, | ||
increment_counter, | ||
state::AppState, | ||
}, | ||
axum::{ | ||
extract::{Path, State}, | ||
http::HeaderMap, | ||
}, | ||
hyper::StatusCode, | ||
std::sync::Arc, | ||
tracing::{error, instrument}, | ||
}; | ||
|
||
#[instrument(skip_all, name = "delete_apns_handler")] | ||
pub async fn handler( | ||
State(state): State<Arc<AppState>>, | ||
Path(id): Path<String>, | ||
headers: HeaderMap, | ||
) -> Result<StatusCode, Error> { | ||
// JWT verification | ||
#[cfg(feature = "cloud")] | ||
let jwt_verification_result = | ||
validate_tenant_request(&state.jwt_validation_client, &headers, &id).await; | ||
|
||
#[cfg(not(feature = "cloud"))] | ||
let jwt_verification_result = validate_tenant_request(&state.jwt_validation_client, &headers); | ||
|
||
if let Err(e) = jwt_verification_result { | ||
error!( | ||
tenant_id = %id, | ||
err = ?e, | ||
"JWT verification failed" | ||
); | ||
return Err(e); | ||
} | ||
|
||
// Ensure tenant real | ||
let _existing_tenant = state.tenant_store.get_tenant(&id).await?; | ||
|
||
let new_tenant = state.tenant_store.update_tenant_delete_apns(&id).await?; | ||
|
||
if new_tenant.suspended { | ||
// If suspended, it can be restored now because valid credentials have been | ||
// provided | ||
state.tenant_store.unsuspend_tenant(&new_tenant.id).await?; | ||
} | ||
|
||
increment_counter!(state.metrics, tenant_apns_updates); | ||
|
||
Ok(StatusCode::NO_CONTENT) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use { | ||
crate::{ | ||
error::Error::{self}, | ||
handlers::validate_tenant_request, | ||
increment_counter, | ||
state::AppState, | ||
}, | ||
axum::{ | ||
extract::{Path, State}, | ||
http::HeaderMap, | ||
}, | ||
hyper::StatusCode, | ||
std::sync::Arc, | ||
tracing::{error, instrument}, | ||
}; | ||
|
||
#[instrument(skip_all, name = "delete_fcm_handler")] | ||
pub async fn handler( | ||
State(state): State<Arc<AppState>>, | ||
Path(id): Path<String>, | ||
headers: HeaderMap, | ||
) -> Result<StatusCode, Error> { | ||
// JWT token verification | ||
#[cfg(feature = "cloud")] | ||
let jwt_verification_result = | ||
validate_tenant_request(&state.jwt_validation_client, &headers, &id).await; | ||
|
||
#[cfg(not(feature = "cloud"))] | ||
let jwt_verification_result = validate_tenant_request(&state.jwt_validation_client, &headers); | ||
|
||
if let Err(e) = jwt_verification_result { | ||
error!( | ||
tenant_id = %id, | ||
err = ?e, | ||
"JWT verification failed" | ||
); | ||
return Err(e); | ||
} | ||
|
||
// -- check if tenant is real | ||
let _existing_tenant = state.tenant_store.get_tenant(&id).await?; | ||
|
||
let new_tenant = state.tenant_store.update_tenant_delete_fcm(&id).await?; | ||
|
||
if new_tenant.suspended { | ||
// If suspended, it can be restored now because valid credentials have been | ||
// provided | ||
state.tenant_store.unsuspend_tenant(&new_tenant.id).await?; | ||
} | ||
|
||
increment_counter!(state.metrics, tenant_fcm_updates); | ||
|
||
Ok(StatusCode::NO_CONTENT) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use { | ||
crate::{ | ||
error::Error::{self}, | ||
handlers::validate_tenant_request, | ||
increment_counter, | ||
state::AppState, | ||
}, | ||
axum::{ | ||
extract::{Path, State}, | ||
http::HeaderMap, | ||
}, | ||
hyper::StatusCode, | ||
std::sync::Arc, | ||
tracing::{debug, error, instrument}, | ||
}; | ||
|
||
#[instrument(skip_all, name = "delete_fcm_v1_handler")] | ||
pub async fn handler( | ||
State(state): State<Arc<AppState>>, | ||
Path(id): Path<String>, | ||
headers: HeaderMap, | ||
) -> Result<StatusCode, Error> { | ||
// JWT token verification | ||
#[cfg(feature = "cloud")] | ||
let jwt_verification_result = | ||
validate_tenant_request(&state.jwt_validation_client, &headers, &id).await; | ||
|
||
// -- check if tenant is real | ||
let _existing_tenant = state.tenant_store.get_tenant(&id).await?; | ||
|
||
#[cfg(not(feature = "cloud"))] | ||
let jwt_verification_result = validate_tenant_request(&state.jwt_validation_client, &headers); | ||
|
||
if let Err(e) = jwt_verification_result { | ||
error!( | ||
tenant_id = %id, | ||
err = ?e, | ||
"JWT verification failed" | ||
); | ||
return Err(e); | ||
} | ||
|
||
let new_tenant = state.tenant_store.update_tenant_delete_fcm_v1(&id).await?; | ||
|
||
if new_tenant.suspended { | ||
// If suspended, it can be restored now because valid credentials have been | ||
// provided | ||
state.tenant_store.unsuspend_tenant(&new_tenant.id).await?; | ||
} | ||
|
||
increment_counter!(state.metrics, tenant_fcm_v1_updates); | ||
|
||
Ok(StatusCode::NO_CONTENT) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.