Skip to content

Commit

Permalink
feat: return data & restrict requests
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryET committed Aug 8, 2023
1 parent 985d7cb commit df8d370
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/handlers/get_tenant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct GetTenantResponse {
enabled_providers: Vec<String>,
apns_topic: Option<String>,
apns_type: Option<ApnsType>,
suspended: bool,
suspended_reason: Option<String>,
}

pub async fn handler(
Expand Down Expand Up @@ -64,6 +66,8 @@ pub async fn handler(
enabled_providers: tenant.providers().iter().map(Into::into).collect(),
apns_topic: None,
apns_type: None,
suspended: tenant.suspended,
suspended_reason: tenant.suspended_reason,
};

if providers.contains(&ProviderKind::Apns) {
Expand Down
4 changes: 4 additions & 0 deletions src/handlers/push_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ pub async fn handler_internal(
"fetched tenant"
);

if tenant.suspended {
return Err((Error::TenantSuspended, analytics.clone()));
}

let mut provider = tenant
.provider(&client.push_type)
.map_err(|e| (e, analytics.clone()))?;
Expand Down

0 comments on commit df8d370

Please sign in to comment.