Skip to content

Commit

Permalink
fix: scope is not an optional param
Browse files Browse the repository at this point in the history
  • Loading branch information
maggie98choy committed Nov 29, 2023
1 parent f8fa784 commit df5b624
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
13 changes: 6 additions & 7 deletions core/main/src/firebolt/handlers/advertising_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub struct AdvertisingIdRPCRequest {

#[derive(Debug, Deserialize, Clone)]
pub struct ScopeOption {
pub scope: Scope,
pub scope: Option<Scope>,
}

#[derive(Debug, Deserialize, Clone)]
Expand Down Expand Up @@ -256,12 +256,11 @@ impl AdvertisingServer for AdvertisingImpl {
) -> RpcResult<AdvertisingId> {
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(
Expand Down
22 changes: 12 additions & 10 deletions core/main/src/firebolt/handlers/privacy_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,18 @@ pub async fn get_allow_app_content_ad_targeting_settings(
) -> HashMap<String, String> {
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();
}
}
}
}
Expand Down

0 comments on commit df5b624

Please sign in to comment.