Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(ios): cancellable pushkit call (#3950)

Peter Chinman4a1ef025520e
diff --git a/infra/stacks/cloud-storage-service/index.ts b/infra/stacks/cloud-storage-service/index.ts
index 9779cb7ce7..2ad52e4929 100644
--- a/infra/stacks/cloud-storage-service/index.ts
+++ b/infra/stacks/cloud-storage-service/index.ts
@@ -655,6 +655,12 @@ const cloudStorageService = new CloudStorageService(
name: 'SNS_APNS_VOIP_PLATFORM_ARN',
value: pulumi.interpolate`${snsApnsVoipPlatformArn}`,
},
+ {
+ // Public base URL native clients use to poll call ring status
+ // while the CallKit incoming-call UI is showing.
+ name: 'CALL_RING_STATUS_BASE_URL',
+ value: getServiceUrl(ServiceUrl.DOCUMENT_STORAGE_SERVICE_URL),
+ },
// OpenTelemetry / Datadog tracing configuration
{
name: 'DD_SERVICE',
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
index ff23d64e13..e99c63b772 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
@@ -779,6 +779,8 @@ export * from './reactionAction';
export * from './recentlyDeletedResponseData';
export * from './removeParticipantsRequest';
export * from './reorderPinRequest';
+export * from './ringStatus';
+export * from './ringStatusResponse';
export * from './s3ObjectInfo';
export * from './saveBomPart';
export * from './saveDocumentRequest';
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/ringStatus.ts b/js/app/packages/service-clients/service-storage/generated/schemas/ringStatus.ts
new file mode 100644
index 0000000000..191b6d8e9f
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/ringStatus.ts
@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Per-user status of an incoming-call ring, as reported by the
+ring-status endpoint while a native client is ringing.
+ */
+export type RingStatus = (typeof RingStatus)[keyof typeof RingStatus];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const RingStatus = {
+ ringing: 'ringing',
+ answered: 'answered',
+ ended: 'ended',
+} as const;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/ringStatusResponse.ts b/js/app/packages/service-clients/service-storage/generated/schemas/ringStatusResponse.ts
new file mode 100644
index 0000000000..1f5f3ab397
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/ringStatusResponse.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { RingStatus } from './ringStatus';
+
+/**
+ * Response body for `GET /call/ring-status/{call_id}`.
+ */
+export interface RingStatusResponse {
+ /** The ring status for the authenticated user. */
+ status: RingStatus;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.ts
index 2764952c9a..ebda929fd0 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -1163,6 +1163,30 @@ export const editCallTranscriptBody = zod
'Body of `PATCH \/call\/record\/{call_id}\/transcript`.\n\nEach entry in `assignments` sets (or clears, when `custom_speaker` is\n`None`) the `custom_speaker` override for every transcript row in the\ncall whose `diarized_speaker_id` matches. Diarized speakers not listed\nare left untouched. Empty `assignments` is a 204 no-op.'
);
+/**
+ * Reports whether the authenticated user should keep ringing for the call.
+Polled by native clients while the CallKit incoming-call UI is showing, so
+a ring can be cancelled when the user answers on another device
+(`answered`) or the call ends before anyone answers (`ended`).
+
+Outside the user-auth layer: the bearer credential is the recipient's
+LiveKit JWT from the VoIP push payload, verified with the LiveKit secret.
+ * @summary Handler for `GET /call/ring-status/{call_id}`.
+ */
+export const getRingStatusParams = zod.object({
+ call_id: zod.uuid().describe('Call ID'),
+});
+
+export const getRingStatusResponse = zod
+ .object({
+ status: zod
+ .enum(['ringing', 'answered', 'ended'])
+ .describe(
+ 'Per-user status of an incoming-call ring, as reported by the\nring-status endpoint while a native client is ringing.'
+ ),
+ })
+ .describe('Response body for `GET \/call\/ring-status\/{call_id}`.');
+
/**
* Gets or creates a call for the channel. If a call already exists, joins it;
otherwise creates a new one. Always returns a join token.
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 4ba3e208f1..2e85463d68 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -969,6 +969,58 @@
}
}
},
+ "/call/ring-status/{call_id}": {
+ "get": {
+ "tags": ["call::inbound::axum_router"],
+ "summary": "Handler for `GET /call/ring-status/{call_id}`.",
+ "description": "Reports whether the authenticated user should keep ringing for the call.\nPolled by native clients while the CallKit incoming-call UI is showing, so\na ring can be cancelled when the user answers on another device\n(`answered`) or the call ends before anyone answers (`ended`).\n\nOutside the user-auth layer: the bearer credential is the recipient's\nLiveKit JWT from the VoIP push payload, verified with the LiveKit secret.",
+ "operationId": "get_ring_status",
+ "parameters": [
+ {
+ "name": "call_id",
+ "in": "path",
+ "description": "Call ID",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "format": "uuid"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/RingStatusResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "Missing or invalid bearer token",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/call/webhook": {
"post": {
"tags": ["call::inbound::axum_router"],
@@ -16558,6 +16610,22 @@
}
}
},
+ "RingStatus": {
+ "type": "string",
+ "description": "Per-user status of an incoming-call ring, as reported by the\nring-status endpoint while a native client is ringing.",
+ "enum": ["ringing", "answered", "ended"]
+ },
+ "RingStatusResponse": {
+ "type": "object",
+ "description": "Response body for `GET /call/ring-status/{call_id}`.",
+ "required": ["status"],
+ "properties": {
+ "status": {
+ "$ref": "#/components/schemas/RingStatus",
+ "description": "The ring status for the authenticated user."
+ }
+ }
+ },
"S3ObjectInfo": {
"type": "object",
"required": ["bucket", "key"],
diff --git a/js/app/tauri/callkit_plugin/ios/Sources/IncomingCallCoordinator.swift b/js/app/tauri/callkit_plugin/ios/Sources/IncomingCallCoordinator.swift
index e6c538ef46..8683d438bc 100644
--- a/js/app/tauri/callkit_plugin/ios/Sources/IncomingCallCoordinator.swift
+++ b/js/app/tauri/callkit_plugin/ios/Sources/IncomingCallCoordinator.swift
@@ -19,6 +19,7 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
private var pendingCalls: [UUID: PendingCallInfo] = [:]
private var pendingCallTokens: [UUID: PendingCallToken] = [:]
+ private var ringPollers: [UUID: RingStatePoller] = [:]
private var activeCallUUID: UUID?
private var activeNativeMediaUUID: UUID?
private var isCallKitAudioSessionActive = false
@@ -172,6 +173,7 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
}
func handleApplicationWillTerminate() {
+ stopAllRingStatePolling()
guard let uuid = activeCallUUID else {
print("[CallKit] Application terminating with no active CallKit call")
return
@@ -226,6 +228,7 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
let callIdString = dict["callId"] as? String ?? ""
let livekitServerUrl = dict["livekitServerUrl"] as? String
let livekitToken = dict["livekitToken"] as? String
+ let ringStatusUrl = dict["ringStatusUrl"] as? String
let hasNativeCredentials = livekitServerUrl != nil && livekitToken != nil
print("[CallKit] Received VoIP push callId=\(callIdString) channelId=\(channelId) channelName=\(channelName ?? "nil") hasNativeCredentials=\(hasNativeCredentials)")
@@ -251,6 +254,7 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
provider.reportCall(with: staleUUID, endedAt: nil, reason: .failed)
pendingCalls.removeValue(forKey: staleUUID)
pendingCallTokens.removeValue(forKey: staleUUID)
+ stopRingStatePolling(uuid: staleUUID)
}
pendingCalls[uuid] = PendingCallInfo(
@@ -281,6 +285,9 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
if self?.activeCallUUID == uuid { self?.activeCallUUID = nil }
} else {
print("[CallKit] reportNewIncomingCall succeeded uuid=\(uuid.uuidString)")
+ if let ringStatusUrl, let token = livekitToken {
+ self?.startRingStatePolling(uuid: uuid, ringStatusUrl: ringStatusUrl, bearerToken: token)
+ }
}
completion()
}
@@ -288,6 +295,7 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
func providerDidReset(_ provider: CXProvider) {
print("[CallKit] CXProvider reset; clearing CallKit and media state")
+ stopAllRingStatePolling()
pendingCalls.removeAll()
pendingCallTokens.removeAll()
activeCallUUID = nil
@@ -343,6 +351,7 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
print("[CallKit] CXAnswerCallAction received uuid=\(action.callUUID.uuidString)")
+ stopRingStatePolling(uuid: action.callUUID)
guard let pendingCall = pendingCalls[action.callUUID] else {
print("[CallKit] Answer failed: no pending channel for uuid=\(action.callUUID.uuidString)")
action.fail()
@@ -456,6 +465,7 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
private func clearCallState(uuid: UUID) {
print("[CallKit] Clearing call state uuid=\(uuid.uuidString)")
+ stopRingStatePolling(uuid: uuid)
pendingCalls.removeValue(forKey: uuid)
pendingCallTokens.removeValue(forKey: uuid)
if activeCallUUID == uuid { activeCallUUID = nil }
@@ -465,6 +475,49 @@ final class IncomingCallCoordinator: NSObject, CXProviderDelegate, PKPushRegistr
pendingAnsweredCall = nil
}
+ private func startRingStatePolling(uuid: UUID, ringStatusUrl: String, bearerToken: String) {
+ guard let url = URL(string: ringStatusUrl) else {
+ print("[CallKit] Invalid ringStatusUrl in VoIP payload uuid=\(uuid.uuidString)")
+ return
+ }
+ stopRingStatePolling(uuid: uuid)
+ let poller = RingStatePoller(uuid: uuid, url: url, bearerToken: bearerToken) { [weak self] uuid, status in
+ self?.handleRemoteRingResolution(uuid: uuid, status: status)
+ }
+ ringPollers[uuid] = poller
+ poller.start()
+ }
+
+ private func stopRingStatePolling(uuid: UUID) {
+ guard let poller = ringPollers.removeValue(forKey: uuid) else { return }
+ poller.cancel()
+ }
+
+ private func stopAllRingStatePolling() {
+ let pollers = Array(ringPollers.values)
+ ringPollers.removeAll()
+ for poller in pollers {
+ poller.cancel()
+ }
+ }
+
+ private func handleRemoteRingResolution(uuid: UUID, status: RingStatePoller.ResolvedStatus) {
+ stopRingStatePolling(uuid: uuid)
+ // A late in-flight response can land after the ring resolved locally
+ // (answered/declined/displaced) — pendingCalls is already empty then.
+ guard pendingCalls[uuid] != nil, activeCallUUID == uuid else {
+ print("[CallKit] Ignoring remote ring resolution; call no longer pending uuid=\(uuid.uuidString)")
+ return
+ }
+ let reason: CXCallEndedReason = status == .answered ? .answeredElsewhere : .remoteEnded
+ print("[CallKit] Ending ringing call from remote resolution uuid=\(uuid.uuidString) reason=\(status == .answered ? "answeredElsewhere" : "remoteEnded")")
+ // reportCall(with:endedAt:reason:) does not trigger the
+ // CXEndCallAction delegate, so notify JS and clear state here.
+ provider.reportCall(with: uuid, endedAt: nil, reason: reason)
+ onCallEnded(uuid.uuidString)
+ clearCallState(uuid: uuid)
+ }
+
private func activateNativeMediaAudioIfNeeded(reason: String) {
guard activeNativeMediaUUID != nil else { return }
guard isCallKitAudioSessionActive else {
diff --git a/js/app/tauri/callkit_plugin/ios/Sources/RingStatePoller.swift b/js/app/tauri/callkit_plugin/ios/Sources/RingStatePoller.swift
new file mode 100644
index 0000000000..951d5c8bf5
--- /dev/null
+++ b/js/app/tauri/callkit_plugin/ios/Sources/RingStatePoller.swift
@@ -0,0 +1,151 @@
+import Foundation
+
+/// Polls the backend ring-status endpoint while a CallKit incoming call is
+/// ringing, so the ring can be ended when the user answers on another device
+/// (answered elsewhere) or the call ends before anyone answers (remote ended).
+///
+/// All mutable state is main-thread only, matching the coordinator's
+/// threading convention; URLSession completion handlers hop to main before
+/// touching state. `onResolved` fires at most once and never after `cancel()`.
+final class RingStatePoller {
+ enum ResolvedStatus {
+ case answered
+ case ended
+ }
+
+ private struct StatusResponse: Decodable {
+ let status: String
+ }
+
+ private let uuid: UUID
+ private let url: URL
+ private let bearerToken: String
+ private let interval: TimeInterval
+ private let window: TimeInterval
+ private let onResolved: (UUID, ResolvedStatus) -> Void
+ private let session: URLSession
+
+ private var deadline: Date?
+ private var pendingTick: DispatchWorkItem?
+ private var isCancelled = false
+ private var isResolved = false
+
+ init(
+ uuid: UUID,
+ url: URL,
+ bearerToken: String,
+ interval: TimeInterval = 1.0,
+ window: TimeInterval = 60.0,
+ onResolved: @escaping (UUID, ResolvedStatus) -> Void
+ ) {
+ self.uuid = uuid
+ self.url = url
+ self.bearerToken = bearerToken
+ self.interval = interval
+ self.window = window
+ self.onResolved = onResolved
+ let config = URLSessionConfiguration.ephemeral
+ config.timeoutIntervalForRequest = 5
+ self.session = URLSession(configuration: config)
+ }
+
+ /// Main-thread only. Starts polling after one interval.
+ func start() {
+ guard deadline == nil, !isCancelled else { return }
+ deadline = Date().addingTimeInterval(window)
+ print("[CallKit] Ring-status polling started uuid=\(uuid.uuidString)")
+ scheduleTick()
+ }
+
+ /// Main-thread only. Idempotent; `onResolved` never fires afterwards.
+ func cancel() {
+ guard !isCancelled else { return }
+ isCancelled = true
+ pendingTick?.cancel()
+ pendingTick = nil
+ session.invalidateAndCancel()
+ print("[CallKit] Ring-status polling cancelled uuid=\(uuid.uuidString)")
+ }
+
+ private func scheduleTick() {
+ guard !isCancelled, !isResolved else { return }
+ guard let deadline, Date().addingTimeInterval(interval) <= deadline else {
+ // Window expired: stop polling and leave the ring as-is.
+ print("[CallKit] Ring-status polling window expired uuid=\(uuid.uuidString)")
+ return
+ }
+ let work = DispatchWorkItem { [weak self] in
+ self?.poll()
+ }
+ pendingTick = work
+ DispatchQueue.main.asyncAfter(deadline: .now() + interval, execute: work)
+ }
+
+ private func poll() {
+ guard !isCancelled, !isResolved else { return }
+ var request = URLRequest(url: url)
+ request.setValue("Bearer \(bearerToken)", forHTTPHeaderField: "Authorization")
+ let task = session.dataTask(with: request) { [weak self] data, response, error in
+ DispatchQueue.main.async {
+ self?.handlePollResult(data: data, response: response, error: error)
+ }
+ }
+ task.resume()
+ }
+
+ private func handlePollResult(data: Data?, response: URLResponse?, error: Error?) {
+ guard !isCancelled, !isResolved else { return }
+
+ if let error {
+ print("[CallKit] Ring-status poll transient error uuid=\(uuid.uuidString) error=\(error.localizedDescription)")
+ scheduleTick()
+ return
+ }
+
+ guard let http = response as? HTTPURLResponse else {
+ scheduleTick()
+ return
+ }
+
+ switch http.statusCode {
+ case 200:
+ break
+ case 401, 403, 404:
+ // Invalid token or a backend without the endpoint — retrying
+ // cannot succeed; stop and leave the ring as-is.
+ print("[CallKit] Ring-status polling stopped uuid=\(uuid.uuidString) httpStatus=\(http.statusCode)")
+ return
+ default:
+ print("[CallKit] Ring-status poll transient HTTP error uuid=\(uuid.uuidString) httpStatus=\(http.statusCode)")
+ scheduleTick()
+ return
+ }
+
+ guard let data,
+ let decoded = try? JSONDecoder().decode(StatusResponse.self, from: data) else {
+ print("[CallKit] Ring-status poll returned undecodable body uuid=\(uuid.uuidString)")
+ scheduleTick()
+ return
+ }
+
+ switch decoded.status {
+ case "answered":
+ resolve(.answered)
+ case "ended":
+ resolve(.ended)
+ case "ringing":
+ scheduleTick()
+ default:
+ print("[CallKit] Ring-status poll returned unknown status '\(decoded.status)' uuid=\(uuid.uuidString)")
+ scheduleTick()
+ }
+ }
+
+ private func resolve(_ status: ResolvedStatus) {
+ guard !isCancelled, !isResolved else { return }
+ isResolved = true
+ pendingTick?.cancel()
+ pendingTick = nil
+ onResolved(uuid, status)
+ }
+}
diff --git a/rust/cloud-storage/ai_tools/src/tool_context.rs b/rust/cloud-storage/ai_tools/src/tool_context.rs
index 7cd169fa49..c76dbc96de 100644
--- a/rust/cloud-storage/ai_tools/src/tool_context.rs
+++ b/rust/cloud-storage/ai_tools/src/tool_context.rs
@@ -273,6 +273,13 @@ impl CallRtcClient for NoOpCallRtcClient {
Err(CallError::Auth)
}
+ fn verify_access_token(
+ &self,
+ _token: &str,
+ ) -> anyhow::Result<call::domain::models::VerifiedRingToken> {
+ anyhow::bail!("call RTC client not configured")
+ }
+
async fn dispatch_transcription_agent(&self, _room_name: &str) -> anyhow::Result<()> {
Ok(())
}
diff --git a/rust/cloud-storage/call/src/domain/models.rs b/rust/cloud-storage/call/src/domain/models.rs
index ea7ce993d2..c6e05659f1 100644
--- a/rust/cloud-storage/call/src/domain/models.rs
+++ b/rust/cloud-storage/call/src/domain/models.rs
@@ -72,6 +72,42 @@ pub struct VoipPushPayloadRequest<'a> {
pub caller_name: &'a str,
/// RTC server URL the native client should connect to.
pub livekit_server_url: &'a str,
+ /// Absolute URL the native client polls while ringing to learn whether
+ /// the call was answered elsewhere or ended. `None` when the service has
+ /// no public base URL configured.
+ pub ring_status_url: Option<&'a str>,
+}
+
+/// Per-user status of an incoming-call ring, as reported by the
+/// ring-status endpoint while a native client is ringing.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]
+#[serde(rename_all = "lowercase")]
+pub enum RingStatus {
+ /// The call is active and this user has not joined yet — keep ringing.
+ Ringing,
+ /// This user joined the call on some device — stop ringing (answered elsewhere).
+ Answered,
+ /// The call is over (or was replaced by a newer call) — stop ringing (remote ended).
+ Ended,
+}
+
+/// Response body for `GET /call/ring-status/{call_id}`.
+#[derive(Debug, serde::Serialize)]
+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]
+#[serde(rename_all = "camelCase")]
+pub struct RingStatusResponse {
+ /// The ring status for the authenticated user.
+ pub status: RingStatus,
+}
+
+/// Identity and room grant extracted from a verified RTC access token.
+#[derive(Debug, Clone)]
+pub struct VerifiedRingToken {
+ /// The participant identity the token was minted for (a Macro user id string).
+ pub identity: String,
+ /// The room the token grants access to, if any.
+ pub room: Option<String>,
}
/// Response for the leave/end call operation.
diff --git a/rust/cloud-storage/call/src/domain/ports.rs b/rust/cloud-storage/call/src/domain/ports.rs
index 803fd30e34..5ddf1f9d9e 100644
--- a/rust/cloud-storage/call/src/domain/ports.rs
+++ b/rust/cloud-storage/call/src/domain/ports.rs
@@ -22,7 +22,8 @@ use super::models::{
CallRecordPreview, CallRecordTranscriptSegment, CallTokenResponse,
CallTranscriptCustomSpeakerResult, CallWebhookEvent, EgressS3Config, EnrichedCallTranscript,
GetBatchCallRecordPreviewRequest, GetBatchCallRecordPreviewResponse, GetCallRecordsRequest,
- LeaveCallResponse, TranscriptSegmentRequest, VoipPushPayloadRequest,
+ LeaveCallResponse, RingStatusResponse, TranscriptSegmentRequest, VerifiedRingToken,
+ VoipPushPayloadRequest,
};
/// Repository port for persisting call state to the database.
@@ -500,6 +501,12 @@ pub trait CallRtcClient: Send + Sync + 'static {
/// Validate a webhook signature and parse the event from the raw body.
fn receive_webhook(&self, body: &str, auth_token: &str) -> Result<CallWebhookEvent, CallError>;
+ /// Verify an access token minted by this deployment (see
+ /// [`generate_token`](Self::generate_token)) and return its identity and
+ /// room grant. Used to authenticate ring-status polling from native
+ /// clients, which present the token delivered in their VoIP push payload.
+ fn verify_access_token(&self, token: &str) -> anyhow::Result<VerifiedRingToken>;
+
/// Dispatch the transcription agent to a room (best-effort).
///
/// Returns `Ok(())` if dispatch succeeded or if no agent is configured.
@@ -536,6 +543,16 @@ pub trait CallService: Send + Sync + 'static {
user_id: MacroUserIdStr<'a>,
) -> impl Future<Output = Result<LeaveCallResponse, CallError>> + Send;
+ /// Report the per-user ring status for a call. The caller authenticates
+ /// with the RTC access token delivered in its VoIP push payload; the
+ /// token's identity determines whose participation is checked. Returns
+ /// [`CallError::Auth`] when the token is invalid or carries no room grant.
+ fn get_ring_status(
+ &self,
+ call_id: &Uuid,
+ bearer_token: &str,
+ ) -> impl Future<Output = Result<RingStatusResponse, CallError>> + Send;
+
/// Validate and process a raw webhook event from the RTC provider.
fn process_webhook_event(
&self,
diff --git a/rust/cloud-storage/call/src/domain/service.rs b/rust/cloud-storage/call/src/domain/service.rs
index 2e1c0de98f..77efda4e70 100644
--- a/rust/cloud-storage/call/src/domain/service.rs
+++ b/rust/cloud-storage/call/src/domain/service.rs
@@ -29,10 +29,11 @@ use crate::domain::models::{
};
use super::models::{
- AddParticipantError, CallActiveResponse, CallError, CallRecord, CallRecordTranscriptSegment,
- CallTokenResponse, CallTranscriptCustomSpeakerResult, EgressS3Config, EnrichedCallTranscript,
- GetBatchCallRecordPreviewRequest, GetBatchCallRecordPreviewResponse, GetCallRecordsRequest,
- LeaveCallResponse, TranscriptSegmentRequest,
+ AddParticipantError, Call, CallActiveResponse, CallError, CallRecord,
+ CallRecordTranscriptSegment, CallTokenResponse, CallTranscriptCustomSpeakerResult,
+ EgressS3Config, EnrichedCallTranscript, GetBatchCallRecordPreviewRequest,
+ GetBatchCallRecordPreviewResponse, GetCallRecordsRequest, LeaveCallResponse, RingStatus,
+ RingStatusResponse, TranscriptSegmentRequest,
};
use super::ports::{
CallRecordQueryService, CallRepository, CallRtcClient, CallSearchIndexer, CallService,
@@ -65,6 +66,7 @@ pub struct CallServiceImpl<
summarizer: Option<Sm>,
voip_push_sender: V,
voice_repo: Vr,
+ ring_status_base_url: Option<String>,
}
impl<
@@ -101,6 +103,7 @@ impl<
summarizer: None,
voip_push_sender: (),
voice_repo: NoOpVoiceRepository,
+ ring_status_base_url: None,
}
}
}
@@ -130,6 +133,14 @@ impl<
self
}
+ /// Set the public base URL used to build the per-call ring-status URL
+ /// included in VoIP push payloads. When unset, payloads omit the URL and
+ /// native clients skip ring-status polling.
+ pub fn with_ring_status_base_url(mut self, base_url: String) -> Self {
+ self.ring_status_base_url = Some(base_url);
+ self
+ }
+
/// Enable AI call summarization with the given [`CallSummarizer`]
/// implementation. When unset, calls are never summarized.
pub fn with_summarizer(mut self, summarizer: Sm) -> Self {
@@ -157,6 +168,7 @@ impl<
summarizer: self.summarizer,
voip_push_sender: sender,
voice_repo: self.voice_repo,
+ ring_status_base_url: self.ring_status_base_url,
}
}
@@ -179,6 +191,7 @@ impl<
summarizer: self.summarizer,
voip_push_sender: self.voip_push_sender,
voice_repo: self.voice_repo,
+ ring_status_base_url: self.ring_status_base_url,
}
}
@@ -201,6 +214,7 @@ impl<
summarizer: self.summarizer,
voip_push_sender: self.voip_push_sender,
voice_repo,
+ ring_status_base_url: self.ring_status_base_url,
}
}
@@ -282,6 +296,25 @@ impl<
}
}
+/// Decide the per-user ring status from the room's active call (if any),
+/// the call id the client is polling for, and whether the user is an
+/// active participant of that call.
+///
+/// A room whose active call differs from the polled one means the polled
+/// call is over and a newer call replaced it — the stale ring is dead.
+fn resolve_ring_status(
+ active_call: Option<&Call>,
+ requested_call_id: &Uuid,
+ is_participant: bool,
+) -> RingStatus {
+ match active_call {
+ None => RingStatus::Ended,
+ Some(call) if call.id != *requested_call_id => RingStatus::Ended,
+ Some(_) if is_participant => RingStatus::Answered,
+ Some(_) => RingStatus::Ringing,
+ }
+}
+
fn exclude_voip_recipients<'a>(
recipient_ids: HashSet<MacroUserIdStr<'a>>,
voip_recipient_ids: &HashSet<MacroUserIdStr<'static>>,
@@ -523,6 +556,14 @@ impl<
.collect();
let voip_channel_name = channel_name.clone().unwrap_or_default();
+ let ring_status_url =
+ self.ring_status_base_url.as_deref().map(|base| {
+ format!(
+ "{}/call/ring-status/{}",
+ base.trim_end_matches('/'),
+ call.id
+ )
+ });
let payloads = self
.rtc_client
.build_voip_push_payloads(VoipPushPayloadRequest {
@@ -533,6 +574,7 @@ impl<
channel_name: &voip_channel_name,
caller_name: &caller_name,
livekit_server_url: &self.server_url,
+ ring_status_url: ring_status_url.as_deref(),
})
.await;
@@ -689,6 +731,45 @@ impl<
})
}
+ #[tracing::instrument(err, skip(self, bearer_token))]
+ async fn get_ring_status(
+ &self,
+ call_id: &Uuid,
+ bearer_token: &str,
+ ) -> Result<RingStatusResponse, CallError> {
+ let verified = self
+ .rtc_client
+ .verify_access_token(bearer_token)
+ .map_err(|e| {
+ tracing::warn!(error=?e, "ring-status token verification failed");
+ CallError::Auth
+ })?;
+ let room = verified.room.ok_or(CallError::Auth)?;
+ let identity =
+ MacroUserIdStr::parse_from_str(&verified.identity).map_err(|_| CallError::Auth)?;
+
+ let active_call = self
+ .repo
+ .get_call_by_room_name(&room)
+ .await
+ .map_err(|e| CallError::Internal(e.into()))?;
+
+ // Only consult participation when the room's active call is the one
+ // being polled — otherwise the answer is Ended regardless.
+ let is_participant = match &active_call {
+ Some(call) if call.id == *call_id => self
+ .repo
+ .is_participant(&call.id, identity.as_ref())
+ .await
+ .map_err(|e| CallError::Internal(e.into()))?,
+ _ => false,
+ };
+
+ Ok(RingStatusResponse {
+ status: resolve_ring_status(active_call.as_ref(), call_id, is_participant),
+ })
+ }
+
#[tracing::instrument(err, skip(self, body, auth_token))]
async fn process_webhook_event(&self, body: &str, auth_token: &str) -> Result<(), CallError> {
let event = self.rtc_client.receive_webhook(body, auth_token)?;
diff --git a/rust/cloud-storage/call/src/domain/service/test.rs b/rust/cloud-storage/call/src/domain/service/test.rs
index 5bbb59459f..ba6833a693 100644
--- a/rust/cloud-storage/call/src/domain/service/test.rs
+++ b/rust/cloud-storage/call/src/domain/service/test.rs
@@ -6,12 +6,15 @@ use macro_user_id::user_id::MacroUserIdStr;
use notification::domain::models::apple::VoipPushPayload;
use uuid::Uuid;
-use crate::domain::models::{CallError, CallWebhookEvent, EgressS3Config, VoipPushPayloadRequest};
+use crate::domain::models::{
+ Call, CallError, CallWebhookEvent, EgressS3Config, RingStatus, VerifiedRingToken,
+ VoipPushPayloadRequest,
+};
use crate::domain::ports::CallRtcClient;
use super::{
derive_preview_key_from_recording_key, derive_preview_keys_from_recording_key,
- exclude_voip_recipients, extract_recording_key,
+ exclude_voip_recipients, extract_recording_key, resolve_ring_status,
};
#[cfg(feature = "outbound")]
@@ -94,6 +97,7 @@ impl CallRtcClient for MockRtcClient {
caller_name: request.caller_name.to_string(),
livekit_server_url: Some(request.livekit_server_url.to_string()),
livekit_token: Some(livekit_token),
+ ring_status_url: request.ring_status_url.map(str::to_string),
},
));
}
@@ -129,6 +133,10 @@ impl CallRtcClient for MockRtcClient {
unreachable!("receive_webhook not exercised by these tests")
}
+ fn verify_access_token(&self, _token: &str) -> anyhow::Result<VerifiedRingToken> {
+ unreachable!("verify_access_token not exercised by these tests")
+ }
+
async fn dispatch_transcription_agent(&self, _room_name: &str) -> anyhow::Result<()> {
unreachable!("dispatch_transcription_agent not exercised by these tests")
}
@@ -302,10 +310,18 @@ async fn build_voip_push_payloads_mints_a_distinct_token_per_recipient() {
channel_name: "general",
caller_name: "Carla",
livekit_server_url: "wss://lk.example",
+ ring_status_url: Some("https://api.example/call/ring-status/0"),
})
.await;
assert_eq!(payloads.len(), 2);
+ for (_, payload) in &payloads {
+ assert_eq!(
+ payload.ring_status_url.as_deref(),
+ Some("https://api.example/call/ring-status/0"),
+ "ring_status_url should propagate into every recipient's payload"
+ );
+ }
let by_id: HashMap<String, String> = payloads
.into_iter()
.map(|(id, p)| {
@@ -341,6 +357,7 @@ async fn build_voip_push_payloads_drops_recipients_whose_token_mint_fails() {
channel_name: "general",
caller_name: "Carla",
livekit_server_url: "wss://lk.example",
+ ring_status_url: None,
})
.await;
@@ -352,6 +369,10 @@ async fn build_voip_push_payloads_drops_recipients_whose_token_mint_fails() {
let (id, payload) = &payloads[0];
assert_eq!(id.as_ref(), alice.as_ref());
assert_eq!(payload.livekit_token.as_deref(), Some("token-alice"));
+ assert_eq!(
+ payload.ring_status_url, None,
+ "payload omits ring_status_url when the service has no base URL configured"
+ );
}
#[tokio::test]
@@ -368,6 +389,7 @@ async fn build_voip_push_payloads_returns_empty_for_no_recipients() {
channel_name: "general",
caller_name: "Carla",
livekit_server_url: "wss://lk.example",
+ ring_status_url: None,
})
.await;
@@ -375,6 +397,57 @@ async fn build_voip_push_payloads_returns_empty_for_no_recipients() {
assert!(mock.calls().is_empty());
}
+fn active_call(call_id: Uuid) -> Call {
+ Call {
+ id: call_id,
+ channel_id: Uuid::nil(),
+ room_name: Uuid::nil().to_string(),
+ created_by: "macro|[email protected]".to_string(),
+ created_at: chrono::Utc::now(),
+ egress_id: None,
+ }
+}
+
+#[test]
+fn resolve_ring_status_reports_ended_when_no_active_call() {
+ let call_id = Uuid::from_u128(1);
+ assert_eq!(
+ resolve_ring_status(None, &call_id, false),
+ RingStatus::Ended
+ );
+}
+
+#[test]
+fn resolve_ring_status_reports_ended_when_a_newer_call_replaced_the_polled_one() {
+ let polled = Uuid::from_u128(1);
+ let newer = active_call(Uuid::from_u128(2));
+ assert_eq!(
+ resolve_ring_status(Some(&newer), &polled, true),
+ RingStatus::Ended,
+ "a different active call in the room means the polled ring is dead"
+ );
+}
+
+#[test]
+fn resolve_ring_status_reports_answered_when_user_is_a_participant() {
+ let call_id = Uuid::from_u128(1);
+ let call = active_call(call_id);
+ assert_eq!(
+ resolve_ring_status(Some(&call), &call_id, true),
+ RingStatus::Answered
+ );
+}
+
+#[test]
+fn resolve_ring_status_reports_ringing_when_user_has_not_joined() {
+ let call_id = Uuid::from_u128(1);
+ let call = active_call(call_id);
+ assert_eq!(
+ resolve_ring_status(Some(&call), &call_id, false),
+ RingStatus::Ringing
+ );
+}
+
#[cfg(feature = "outbound")]
#[sqlx::test(
fixtures(path = "../../../fixtures", scripts("call_repo")),
diff --git a/rust/cloud-storage/call/src/inbound/axum_router.rs b/rust/cloud-storage/call/src/inbound/axum_router.rs
index 029ad3037d..199bc7b7c7 100644
--- a/rust/cloud-storage/call/src/inbound/axum_router.rs
+++ b/rust/cloud-storage/call/src/inbound/axum_router.rs
@@ -34,7 +34,7 @@ use uuid::Uuid;
use crate::domain::models::{
CallActiveResponse, CallError, CallRecord, CallTokenResponse, EditCallRecordRequest,
EditCallTranscriptRequest, GetBatchCallRecordPreviewRequest, GetBatchCallRecordPreviewResponse,
- LeaveCallResponse, MAX_BATCH_CALL_IDS, TranscriptSegmentRequest,
+ LeaveCallResponse, MAX_BATCH_CALL_IDS, RingStatusResponse, TranscriptSegmentRequest,
};
use crate::domain::ports::CallService;
@@ -145,10 +145,13 @@ impl<S: CallService> WebhookRouterState<S> {
}
}
-/// Webhook router for RTC provider event ingestion.
+/// Webhook router for endpoints outside the user-auth layer; each handler
+/// validates its own credentials.
///
/// Routes:
-/// - `POST /webhook` — ingest a webhook event from LiveKit
+/// - `POST /webhook` — ingest a webhook event from LiveKit (signed by LiveKit)
+/// - `GET /ring-status/{call_id}` — per-user ring status, authenticated with
+/// the LiveKit JWT delivered in the VoIP push payload
pub fn webhook_router<S, T>(state: WebhookRouterState<S>) -> Router<T>
where
S: CallService,
@@ -156,6 +159,7 @@ where
{
Router::new()
.route("/webhook", post(webhook_handler::<S>))
+ .route("/ring-status/{call_id}", get(ring_status_handler::<S>))
.with_state(state)
}
@@ -568,6 +572,45 @@ pub async fn webhook_handler<S: CallService>(
Ok(StatusCode::OK)
}
+/// Handler for `GET /call/ring-status/{call_id}`.
+///
+/// Reports whether the authenticated user should keep ringing for the call.
+/// Polled by native clients while the CallKit incoming-call UI is showing, so
+/// a ring can be cancelled when the user answers on another device
+/// (`answered`) or the call ends before anyone answers (`ended`).
+///
+/// Outside the user-auth layer: the bearer credential is the recipient's
+/// LiveKit JWT from the VoIP push payload, verified with the LiveKit secret.
+#[utoipa::path(
+ get,
+ operation_id = "get_ring_status",
+ path = "/call/ring-status/{call_id}",
+ params(
+ ("call_id" = Uuid, Path, description = "Call ID"),
+ ),
+ responses(
+ (status = 200, body = RingStatusResponse),
+ (status = 401, body = ErrorResponse, description = "Missing or invalid bearer token"),
+ (status = 500, body = ErrorResponse),
+ )
+)]
+#[tracing::instrument(err, skip_all)]
+pub async fn ring_status_handler<S: CallService>(
+ State(state): State<WebhookRouterState<S>>,
+ axum::extract::Path(call_id): axum::extract::Path<Uuid>,
+ headers: axum::http::HeaderMap,
+) -> Result<Json<RingStatusResponse>, CallError> {
+ let bearer = headers
+ .get(axum::http::header::AUTHORIZATION)
+ .and_then(|v| v.to_str().ok())
+ .and_then(|v| v.strip_prefix("Bearer "))
+ .ok_or(CallError::Auth)?;
+
+ let response = state.service.get_ring_status(&call_id, bearer).await?;
+
+ Ok(Json(response))
+}
+
/// Handler for `POST /call/{channel_id}/transcript`.
///
/// Receives transcript segments from the transcription agent.
diff --git a/rust/cloud-storage/call/src/outbound/livekit_rtc_client.rs b/rust/cloud-storage/call/src/outbound/livekit_rtc_client.rs
index 4257c7919a..8c544c7a3b 100644
--- a/rust/cloud-storage/call/src/outbound/livekit_rtc_client.rs
+++ b/rust/cloud-storage/call/src/outbound/livekit_rtc_client.rs
@@ -3,6 +3,9 @@
//! Wraps the `livekit-api` crate to provide room management, token generation,
//! egress recording, and webhook validation.
+#[cfg(test)]
+mod test;
+
use futures::future;
use livekit_api::access_token::{AccessToken, TokenVerifier, VideoGrants};
use livekit_api::services::agent_dispatch::AgentDispatchClient;
@@ -17,7 +20,9 @@ use macro_user_id::cowlike::CowLike;
use macro_user_id::user_id::MacroUserIdStr;
use notification::domain::models::apple::VoipPushPayload;
-use crate::domain::models::{CallError, CallWebhookEvent, EgressS3Config, VoipPushPayloadRequest};
+use crate::domain::models::{
+ CallError, CallWebhookEvent, EgressS3Config, VerifiedRingToken, VoipPushPayloadRequest,
+};
use crate::domain::ports::CallRtcClient;
const VOIP_TOKEN_MINT_CONCURRENCY: usize = 16;
@@ -28,6 +33,7 @@ pub struct LivekitRtcClient {
egress_client: EgressClient,
agent_dispatch_client: AgentDispatchClient,
webhook_receiver: WebhookReceiver,
+ token_verifier: TokenVerifier,
api_key: String,
api_secret: String,
/// If set, the named agent is dispatched to each new room for transcription.
@@ -60,13 +66,14 @@ impl LivekitRtcClient {
let egress_client = EgressClient::with_api_key(&http_url, &api_key, &api_secret);
let agent_dispatch_client =
AgentDispatchClient::with_api_key(&http_url, &api_key, &api_secret);
- let verifier = TokenVerifier::with_api_key(&api_key, &api_secret);
- let webhook_receiver = WebhookReceiver::new(verifier);
+ let token_verifier = TokenVerifier::with_api_key(&api_key, &api_secret);
+ let webhook_receiver = WebhookReceiver::new(token_verifier.clone());
Self {
room_client,
egress_client,
agent_dispatch_client,
webhook_receiver,
+ token_verifier,
api_key,
api_secret,
transcription_agent_name,
@@ -176,6 +183,7 @@ impl CallRtcClient for LivekitRtcClient {
let channel_name = request.channel_name;
let caller_name = request.caller_name;
let livekit_server_url = request.livekit_server_url;
+ let ring_status_url = request.ring_status_url;
let mut payloads = Vec::new();
for batch in request.recipients.chunks(VOIP_TOKEN_MINT_CONCURRENCY) {
@@ -193,6 +201,7 @@ impl CallRtcClient for LivekitRtcClient {
caller_name: caller_name.to_string(),
livekit_server_url: Some(livekit_server_url.to_string()),
livekit_token: Some(livekit_token),
+ ring_status_url: ring_status_url.map(str::to_string),
},
)),
Err(e) => {
@@ -264,6 +273,18 @@ impl CallRtcClient for LivekitRtcClient {
Ok(())
}
+ fn verify_access_token(&self, token: &str) -> anyhow::Result<VerifiedRingToken> {
+ let claims = self
+ .token_verifier
+ .verify(token)
+ .map_err(|e| anyhow::anyhow!("access token verification failed: {e}"))?;
+
+ Ok(VerifiedRingToken {
+ identity: claims.sub,
+ room: Some(claims.video.room).filter(|r| !r.is_empty()),
+ })
+ }
+
fn receive_webhook(&self, body: &str, auth_token: &str) -> Result<CallWebhookEvent, CallError> {
let event = self
.webhook_receiver
diff --git a/rust/cloud-storage/call/src/outbound/livekit_rtc_client/test.rs b/rust/cloud-storage/call/src/outbound/livekit_rtc_client/test.rs
new file mode 100644
index 0000000000..7ddc6f4080
--- /dev/null
+++ b/rust/cloud-storage/call/src/outbound/livekit_rtc_client/test.rs
@@ -0,0 +1,50 @@
+use macro_user_id::user_id::MacroUserIdStr;
+
+use super::*;
+use crate::domain::ports::CallRtcClient as _;
+
+fn client() -> LivekitRtcClient {
+ LivekitRtcClient::new(
+ "wss://lk.example",
+ "test-api-key",
+ "test-api-secret-test-api-secret-test",
+ None,
+ )
+}
+
+#[tokio::test]
+async fn verify_access_token_round_trips_identity_and_room() {
+ let client = client();
+ let identity = MacroUserIdStr::try_from_email("[email protected]").unwrap();
+
+ let token = client
+ .generate_token("room-1", identity.clone())
+ .await
+ .expect("token mint is pure JWT crypto, no network");
+
+ let verified = client.verify_access_token(&token).expect("token verifies");
+ assert_eq!(verified.identity, identity.as_ref());
+ assert_eq!(verified.room.as_deref(), Some("room-1"));
+}
+
+#[tokio::test]
+async fn verify_access_token_rejects_token_signed_with_a_different_secret() {
+ let identity = MacroUserIdStr::try_from_email("[email protected]").unwrap();
+ let token = client()
+ .generate_token("room-1", identity)
+ .await
+ .expect("token mint is pure JWT crypto, no network");
+
+ let other = LivekitRtcClient::new(
+ "wss://lk.example",
+ "test-api-key",
+ "a-completely-different-secret-value!",
+ None,
+ );
+ assert!(other.verify_access_token(&token).is_err());
+}
+
+#[test]
+fn verify_access_token_rejects_garbage() {
+ assert!(client().verify_access_token("not-a-jwt").is_err());
+}
diff --git a/rust/cloud-storage/document_storage_service/src/api/swagger.rs b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
index f9e430d739..ff84d194cc 100644
--- a/rust/cloud-storage/document_storage_service/src/api/swagger.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
@@ -252,6 +252,7 @@ use utoipa::OpenApi;
call::inbound::axum_router::toggle_share_with_team_handler,
call::inbound::axum_router::get_batch_call_record_preview_handler,
call::inbound::axum_router::webhook_handler,
+ call::inbound::axum_router::ring_status_handler,
call::inbound::axum_router::transcript_handler,
// pins
@@ -493,6 +494,8 @@ use utoipa::OpenApi;
call::domain::models::WithCallId,
call::domain::models::GetBatchCallRecordPreviewRequest,
call::domain::models::GetBatchCallRecordPreviewResponse,
+ call::domain::models::RingStatus,
+ call::domain::models::RingStatusResponse,
SoupCallRecord,
SoupCallRecordParticipant,
diff --git a/rust/cloud-storage/document_storage_service/src/config.rs b/rust/cloud-storage/document_storage_service/src/config.rs
index 035b128ae7..5242e56d86 100644
--- a/rust/cloud-storage/document_storage_service/src/config.rs
+++ b/rust/cloud-storage/document_storage_service/src/config.rs
@@ -87,6 +87,13 @@ maybe_env_var! {
pub struct InternalCallSecret;
}
+maybe_env_var! {
+ /// Public base URL of this service (e.g. `https://cloud-storage.macro.com`),
+ /// used to build the ring-status URL included in VoIP push payloads.
+ /// When unset, payloads omit the URL and native ring-status polling is off.
+ pub struct CallRingStatusBaseUrl;
+}
+
maybe_env_var! {
/// S3 bucket for call recording egress.
pub struct CallRecordingS3Bucket;
diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rs
index a7e031575c..d5317010ef 100644
--- a/rust/cloud-storage/document_storage_service/src/main.rs
+++ b/rust/cloud-storage/document_storage_service/src/main.rs
@@ -512,6 +512,10 @@ async fn main() -> anyhow::Result<()> {
if let Some(config) = egress_config {
call_service_builder = call_service_builder.with_egress(config);
}
+ if let Some(base_url) = config::CallRingStatusBaseUrl::new() {
+ call_service_builder =
+ call_service_builder.with_ring_status_base_url(base_url.as_ref().to_owned());
+ }
// VoIP push is optional: enabled only when both env vars are present.
// APPLE_BUNDLE_ID: the app bundle ID (e.g. "com.macro.app.prod")
diff --git a/rust/cloud-storage/notification/src/domain/models/apple.rs b/rust/cloud-storage/notification/src/domain/models/apple.rs
index 344ef6c96c..4078abcf0e 100644
--- a/rust/cloud-storage/notification/src/domain/models/apple.rs
+++ b/rust/cloud-storage/notification/src/domain/models/apple.rs
@@ -187,6 +187,11 @@ pub struct VoipPushPayload {
/// Recipient-specific LiveKit JWT for native lock-screen answers.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub livekit_token: Option<String>,
+ /// Absolute URL the native client polls while ringing to learn whether
+ /// the call was answered elsewhere or ended. Authenticated with
+ /// `livekit_token` as the bearer credential.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub ring_status_url: Option<String>,
}
/// the value we send as the payload in the ios notification
diff --git a/rust/cloud-storage/notification/src/domain/service/voip/test.rs b/rust/cloud-storage/notification/src/domain/service/voip/test.rs
index dd2dc32623..65d4a6a78f 100644
--- a/rust/cloud-storage/notification/src/domain/service/voip/test.rs
+++ b/rust/cloud-storage/notification/src/domain/service/voip/test.rs
@@ -28,6 +28,9 @@ fn payload() -> VoipPushPayload {
caller_name: "Alice".to_string(),
livekit_server_url: Some("wss://livekit.example".to_string()),
livekit_token: Some("test-token".to_string()),
+ ring_status_url: Some(
+ "https://api.example/call/ring-status/11111111-1111-1111-1111-111111111111".to_string(),
+ ),
}
}