Bug 1965086 - Vendor app-services 72a070750ff979f4aac29da7c02a9cb6e53ac087, r=nanj

Differential Revision: https://phabricator.services.mozilla.com/D248466
This commit is contained in:
Ben Dean-Kawamura
2025-05-15 14:17:20 +00:00
committed by bdeankawamura@mozilla.com
parent daeadd1d46
commit 7b45ba29ff
6 changed files with 111 additions and 32 deletions

View File

@@ -70,9 +70,9 @@ git = "https://github.com/jfkthame/mapped_hyph.git"
rev = "eff105f6ad7ec9b79816cfc1985a28e5340ad14b"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197"]
[source."git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087"]
git = "https://github.com/mozilla/application-services"
rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197"
rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/audioipc?rev=e6f44a2bd1e57d11dfc737632a9e849077632330"]

32
Cargo.lock generated
View File

@@ -1894,7 +1894,7 @@ dependencies = [
[[package]]
name = "error-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"error-support-macros",
"lazy_static",
@@ -1906,7 +1906,7 @@ dependencies = [
[[package]]
name = "error-support-macros"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"proc-macro2",
"quote",
@@ -2025,7 +2025,7 @@ dependencies = [
[[package]]
name = "firefox-versioning"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"serde_json",
"thiserror 1.999.999",
@@ -3365,7 +3365,7 @@ dependencies = [
[[package]]
name = "interrupt-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"lazy_static",
"parking_lot",
@@ -5086,7 +5086,7 @@ checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
[[package]]
name = "payload-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"serde",
"serde_derive",
@@ -5589,7 +5589,7 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "relevancy"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"anyhow",
"base64 0.21.999",
@@ -5614,7 +5614,7 @@ dependencies = [
[[package]]
name = "remote_settings"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"anyhow",
"camino",
@@ -5916,7 +5916,7 @@ dependencies = [
[[package]]
name = "search"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"error-support",
"firefox-versioning",
@@ -6208,7 +6208,7 @@ dependencies = [
[[package]]
name = "sql-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"interrupt-support",
"lazy_static",
@@ -6414,7 +6414,7 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "suggest"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"anyhow",
"chrono",
@@ -6466,7 +6466,7 @@ dependencies = [
[[package]]
name = "sync-guid"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"base64 0.21.999",
"rand",
@@ -6477,7 +6477,7 @@ dependencies = [
[[package]]
name = "sync15"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"anyhow",
"error-support",
@@ -6517,7 +6517,7 @@ dependencies = [
[[package]]
name = "tabs"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"anyhow",
"error-support",
@@ -6861,7 +6861,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "types"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"rusqlite 0.33.0",
"serde",
@@ -7264,7 +7264,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "viaduct"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"ffi-support",
"log",
@@ -7434,7 +7434,7 @@ dependencies = [
[[package]]
name = "webext-storage"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=40ae79e2825fa242a349e17fcfc84fb99fd92197#40ae79e2825fa242a349e17fcfc84fb99fd92197"
source = "git+https://github.com/mozilla/application-services?rev=72a070750ff979f4aac29da7c02a9cb6e53ac087#72a070750ff979f4aac29da7c02a9cb6e53ac087"
dependencies = [
"anyhow",
"error-support",

View File

@@ -262,14 +262,14 @@ wr_malloc_size_of = { path = "gfx/wr/wr_malloc_size_of" }
objc = { git = "https://github.com/glandium/rust-objc", rev = "4de89f5aa9851ceca4d40e7ac1e2759410c04324" }
# application-services overrides to make updating them all simpler.
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
relevancy = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
search = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "40ae79e2825fa242a349e17fcfc84fb99fd92197" }
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
relevancy = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
search = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "72a070750ff979f4aac29da7c02a9cb6e53ac087" }
allocator-api2 = { path = "third_party/rust/allocator-api2" }

File diff suppressed because one or more lines are too long

View File

@@ -507,9 +507,15 @@ impl RemoteSettingsClient<ViaductApiClient> {
Self::new_from_parts(collection_name, storage, jexl_filter, api_client)
}
pub fn update_config(&self, server_url: BaseUrl, bucket_name: String) -> Result<()> {
pub fn update_config(
&self,
server_url: BaseUrl,
bucket_name: String,
context: Option<RemoteSettingsContext>,
) -> Result<()> {
let mut inner = self.inner.lock();
inner.api_client = ViaductApiClient::new(server_url, &bucket_name, &self.collection_name);
inner.jexl_filter = JexlFilter::new(context);
inner.storage.empty()
}
}
@@ -2040,6 +2046,76 @@ mod jexl_tests {
Some(vec![])
);
}
#[test]
fn test_update_jexl_context() {
let mut api_client = MockApiClient::new();
let records = vec![RemoteSettingsRecord {
id: "record-0001".into(),
last_modified: 100,
deleted: false,
attachment: None,
fields: serde_json::json!({
"filter_expression": "env.country == \"US\""
})
.as_object()
.unwrap()
.clone(),
}];
let changeset = ChangesetResponse {
changes: records.clone(),
timestamp: 42,
metadata: CollectionMetadata::default(),
};
api_client.expect_collection_url().returning(|| {
"http://rs.example.com/v1/buckets/main/collections/test-collection".into()
});
api_client.expect_fetch_changeset().returning({
let changeset = changeset.clone();
move |timestamp| {
assert_eq!(timestamp, None);
Ok(changeset.clone())
}
});
api_client.expect_is_prod_server().returning(|| Ok(false));
let context = RemoteSettingsContext {
country: Some("US".to_string()),
..Default::default()
};
let mut storage = Storage::new(":memory:".into());
let _ = storage.insert_collection_content(
"http://rs.example.com/v1/buckets/main/collections/test-collection",
&records,
42,
CollectionMetadata::default(),
);
let rs_client = RemoteSettingsClient::new_from_parts(
"test-collection".into(),
storage,
JexlFilter::new(Some(context)),
api_client,
);
assert_eq!(
rs_client.get_records(false).expect("Error getting records"),
Some(records)
);
// We can't call `update_config` directly, since that only works with a real API client.
// Instead, just execute the code from that method that updates the JEXL filter.
rs_client.inner.lock().jexl_filter = JexlFilter::new(Some(RemoteSettingsContext {
country: Some("UK".to_string()),
..Default::default()
}));
assert_eq!(
rs_client.get_records(false).expect("Error getting records"),
Some(vec![])
);
}
}
#[cfg(feature = "signatures")]

View File

@@ -105,12 +105,15 @@ impl RemoteSettingsService {
let bucket_name = config.bucket_name.unwrap_or_else(|| String::from("main"));
let mut inner = self.inner.lock();
for client in inner.active_clients() {
client
.internal
.update_config(base_url.clone(), bucket_name.clone())?;
client.internal.update_config(
base_url.clone(),
bucket_name.clone(),
config.app_context.clone(),
)?;
}
inner.base_url = base_url;
inner.bucket_name = bucket_name;
inner.app_context = config.app_context;
Ok(())
}
}