From df5b624857cd9bd7ab5ed181d40dc4591852d258 Mon Sep 17 00:00:00 2001 From: Maggie Choy Date: Wed, 29 Nov 2023 11:29:03 -0800 Subject: [PATCH] fix: scope is not an optional param --- .../src/firebolt/handlers/advertising_rpc.rs | 13 +++++------ .../main/src/firebolt/handlers/privacy_rpc.rs | 22 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/core/main/src/firebolt/handlers/advertising_rpc.rs b/core/main/src/firebolt/handlers/advertising_rpc.rs index 2dff98c88..1833655a0 100644 --- a/core/main/src/firebolt/handlers/advertising_rpc.rs +++ b/core/main/src/firebolt/handlers/advertising_rpc.rs @@ -104,7 +104,7 @@ pub struct AdvertisingIdRPCRequest { #[derive(Debug, Deserialize, Clone)] pub struct ScopeOption { - pub scope: Scope, + pub scope: Option, } #[derive(Debug, Deserialize, Clone)] @@ -256,12 +256,11 @@ impl AdvertisingServer for AdvertisingImpl { ) -> RpcResult { let session = self.state.session_state.get_account_session().unwrap(); let mut scope_option_map = HashMap::new(); - if let Some(req_opt) = &request.options { - scope_option_map.insert( - "type".to_string(), - req_opt.scope._type.as_string().to_string(), - ); - scope_option_map.insert("id".to_string(), req_opt.scope.id.to_string()); + if let Some(scope_opt) = &request.options { + if let Some(scope) = &scope_opt.scope { + scope_option_map.insert("type".to_string(), scope._type.as_string().to_string()); + scope_option_map.insert("id".to_string(), scope.id.to_string()); + } } let payload = AdvertisingRequest::GetAdIdObject(AdIdRequestParams { privacy_data: privacy_rpc::get_allow_app_content_ad_targeting_settings( diff --git a/core/main/src/firebolt/handlers/privacy_rpc.rs b/core/main/src/firebolt/handlers/privacy_rpc.rs index 1654ff3a6..9a70dbfa6 100644 --- a/core/main/src/firebolt/handlers/privacy_rpc.rs +++ b/core/main/src/firebolt/handlers/privacy_rpc.rs @@ -280,16 +280,18 @@ pub async fn get_allow_app_content_ad_targeting_settings( ) -> HashMap { let mut data = StorageProperty::AllowAppContentAdTargeting.as_data(); if let Some(scope_opt) = scope_option { - let primary_app = platform_state - .get_device_manifest() - .applications - .defaults - .main; - if primary_app == *caller_app.to_string() { - if scope_opt.scope._type.as_string() == "browse" { - data = StorageProperty::AllowPrimaryBrowseAdTargeting.as_data(); - } else if scope_opt.scope._type.as_string() == "content" { - data = StorageProperty::AllowPrimaryContentAdTargeting.as_data(); + if let Some(scope) = &scope_opt.scope { + let primary_app = platform_state + .get_device_manifest() + .applications + .defaults + .main; + if primary_app == *caller_app.to_string() { + if scope._type.as_string() == "browse" { + data = StorageProperty::AllowPrimaryBrowseAdTargeting.as_data(); + } else if scope._type.as_string() == "content" { + data = StorageProperty::AllowPrimaryContentAdTargeting.as_data(); + } } } }