Skip to content

Commit 7f873b0

Browse files
authored
feat(relay): add site eligibility check for Relay with Remote Settings (#7039)
Adds Remote Settings integration to enable mobile clients to determine whether to show Firefox Relay UI based on site allowlist/denylist and user Relay account status. - Add new `RelayRemoteSettingsClient` in rs.rs module - Fetches allowlist/denylist from Remote Settings collections - Implements `should_show_relay()` with three-factor decision logic - Includes subdomain-aware domain matching (not PSL-aware)
1 parent 3baae97 commit 7f873b0

File tree

8 files changed

+470
-0
lines changed

8 files changed

+470
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
### Autofill
66
- Adds a migration to migrate users to use subregion codes over fully qualified strings. ([bug 1993388](https://bugzilla.mozilla.org/show_bug.cgi?id=1993388))
77

8+
### Relay
9+
- Added Remote Settings integration to determine site eligibility for displaying Relay UI. The new `RelayRemoteSettingsClient` fetches allowlist/denylist data, and `should_show_relay()` provides subdomain-aware domain matching to decide when to show Relay email mask suggestions. ([#7039](https://github.com/mozilla/application-services/pull/7039))
10+
811
## 🦊 What's Changed 🦊
912

1013
### Android

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/relay/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66
[dependencies]
77
error-support = { path = "../support/error", features = ["tracing-logging"] }
88
log = "0.4"
9+
remote_settings = { path = "../remote_settings" }
910
serde = { version = "1", features=["derive"] }
1011
serde_json = "1"
1112
thiserror = "2"

components/relay/android/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ android {
55
namespace 'org.mozilla.appservices.relay'
66
}
77

8+
dependencies {
9+
api project(":remotesettings")
10+
}
11+
812
ext.configureUniFFIBindgen("relay")
913
ext.dependsOnTheMegazord()
1014
ext.configurePublish()

components/relay/src/error.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
pub use error_support::error;
66
use error_support::{ErrorHandling, GetErrorHandling};
7+
use remote_settings::RemoteSettingsError;
78

89
pub type Result<T> = std::result::Result<T, Error>;
910
pub type ApiResult<T> = std::result::Result<T, RelayApiError>;
@@ -42,6 +43,12 @@ pub enum Error {
4243
Viaduct(#[from] viaduct::ViaductError),
4344
#[error("URL parsing error: {0}")]
4445
UrlParse(#[from] url::ParseError),
46+
47+
#[error("Error from Remote Settings: {0}")]
48+
RemoteSettings(#[from] RemoteSettingsError),
49+
50+
#[error("Failed to parse Remote Settings record: {0}")]
51+
InvalidRemoteSettingsRecord(String),
4552
}
4653

4754
impl GetErrorHandling for Error {
@@ -73,6 +80,24 @@ impl GetErrorHandling for Error {
7380
})
7481
.report_error("relay-api-error")
7582
}
83+
// Handle Remote Settings errors
84+
// Note: these are just logged/reported but not exposed to consumers
85+
Error::RemoteSettings(RemoteSettingsError::Network { reason }) => {
86+
ErrorHandling::convert(RelayApiError::Other {
87+
reason: format!("Remote Settings network error: {}", reason),
88+
})
89+
.log_warning()
90+
}
91+
Error::RemoteSettings(e) => ErrorHandling::convert(RelayApiError::Other {
92+
reason: format!("Remote Settings error: {}", e),
93+
})
94+
.report_error("relay-rs-error"),
95+
Error::InvalidRemoteSettingsRecord(msg) => {
96+
ErrorHandling::convert(RelayApiError::Other {
97+
reason: format!("Invalid Remote Settings record: {}", msg),
98+
})
99+
.report_error("relay-invalid-record")
100+
}
76101
_ => ErrorHandling::convert(RelayApiError::Other {
77102
reason: self.to_string(),
78103
})

components/relay/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
mod error;
6+
mod rs;
67

78
uniffi::setup_scaffolding!("relay");
89

0 commit comments

Comments
 (0)