commit 10811bcec0fe69e7fc7c10bc33dc3cedf7cc119e
parent bceee66d097b580bf91fa58c1c4571b08fb041f8
Author: Gela <gmalekpour@mozilla.com>
Date: Wed, 10 Dec 2025 03:54:45 +0000
Bug 2004776 - Wrap fetch_profile rust code r=android-reviewers,mavduevskiy
Differential Revision: https://phabricator.services.mozilla.com/D275531
Diffstat:
1 file changed, 16 insertions(+), 0 deletions(-)
diff --git a/mobile/android/android-components/components/service/firefox-relay/src/main/java/mozilla/components/service/fxrelay/FxRelay.kt b/mobile/android/android-components/components/service/firefox-relay/src/main/java/mozilla/components/service/fxrelay/FxRelay.kt
@@ -8,6 +8,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import mozilla.appservices.relay.RelayApiException
import mozilla.appservices.relay.RelayClient
+import mozilla.appservices.relay.RelayProfile
import mozilla.components.support.base.log.logger.Logger
/**
@@ -34,6 +35,7 @@ class FxRelay(
CREATE_ADDRESS,
ACCEPT_TERMS,
FETCH_ALL_ADDRESSES,
+ FETCH_PROFILE,
}
/**
@@ -114,4 +116,18 @@ class FxRelay(
client.fetchAddresses().map { it.into() }
}
}
+
+ /**
+ * Retrieves the [RelayProfile] for the authenticated user.
+ *
+ * @return The user's [RelayProfile] or `null` if the operation failed.
+ */
+ suspend fun fetchProfile(): RelayProfile? = withContext(Dispatchers.IO) {
+ handleRelayExceptions(
+ RelayOperation.FETCH_PROFILE,
+ { null },
+ ) {
+ client.fetchProfile()
+ }
+ }
}