Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(call): support get call record endpoint (#2528)
Will Hutchinsone982cee409ba
diff --git a/js/app/packages/queries/notification/user-notifications.ts b/js/app/packages/queries/notification/user-notifications.tsindex 1b54f97e3d..9086faf193 100644--- a/js/app/packages/queries/notification/user-notifications.ts+++ b/js/app/packages/queries/notification/user-notifications.ts@@ -401,7 +401,7 @@ function notificationEntityTypeToSoupTag(.with('channel', () => 'channel' as const).with('project', () => 'project' as const).with('email_thread', () => 'emailThread' as const)- .with(P.union('user', 'team'), () => null)+ .with(P.union('user', 'team', 'call'), () => null).exhaustive();}diff --git a/js/app/packages/service-clients/service-connection/generated/schemas/entityType.ts b/js/app/packages/service-clients/service-connection/generated/schemas/entityType.tsindex 4a984ebf8f..fd7ac254e1 100644--- a/js/app/packages/service-clients/service-connection/generated/schemas/entityType.ts+++ b/js/app/packages/service-clients/service-connection/generated/schemas/entityType.ts@@ -19,4 +19,5 @@ export const EntityType = {project: 'project',email_thread: 'email_thread',team: 'team',+ call: 'call',} as const;diff --git a/js/app/packages/service-clients/service-connection/openapi.json b/js/app/packages/service-clients/service-connection/openapi.jsonindex b0d978d1f4..a5e118dac0 100644--- a/js/app/packages/service-clients/service-connection/openapi.json+++ b/js/app/packages/service-clients/service-connection/openapi.json@@ -236,7 +236,8 @@"document","project","email_thread",- "team"+ "team",+ "call"]},"GenericErrorResponse": {diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/entityType.ts b/js/app/packages/service-clients/service-notification/generated/schemas/entityType.tsindex 825bc35002..981e162fb9 100644--- a/js/app/packages/service-clients/service-notification/generated/schemas/entityType.ts+++ b/js/app/packages/service-clients/service-notification/generated/schemas/entityType.ts@@ -19,4 +19,5 @@ export const EntityType = {project: 'project',email_thread: 'email_thread',team: 'team',+ call: 'call',} as const;diff --git a/js/app/packages/service-clients/service-notification/generated/zod.ts b/js/app/packages/service-clients/service-notification/generated/zod.tsindex f62a704cea..f2d02df866 100644--- a/js/app/packages/service-clients/service-notification/generated/zod.ts+++ b/js/app/packages/service-clients/service-notification/generated/zod.ts@@ -115,6 +115,7 @@ export const listTypedNotificationsResponse = zod'project','email_thread','team',+ 'call',]).describe('The type of an entity in Macro'),})@@ -546,6 +547,7 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod'project','email_thread','team',+ 'call',]).describe('The type of an entity in Macro'),})@@ -971,6 +973,7 @@ export const getTypedNotificationsByEventItemIdResponse = zod'project','email_thread','team',+ 'call',]).describe('The type of an entity in Macro'),})@@ -1407,6 +1410,7 @@ export const getTypedNotificationByIdResponse = zod'project','email_thread','team',+ 'call',]).describe('The type of an entity in Macro'),})diff --git a/js/app/packages/service-clients/service-notification/openapi.json b/js/app/packages/service-clients/service-notification/openapi.jsonindex 2784bc55d7..92b5cf16d1 100644--- a/js/app/packages/service-clients/service-notification/openapi.json+++ b/js/app/packages/service-clients/service-notification/openapi.json@@ -1452,7 +1452,8 @@"document","project","email_thread",- "team"+ "team",+ "call"]},"ErrorResponse": {diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecord.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecord.tsnew file mode 100644index 0000000000..0721f1da06--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecord.ts@@ -0,0 +1,40 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { CallRecordDurationMs } from './callRecordDurationMs';+import type { CallRecordEgressId } from './callRecordEgressId';+import type { CallRecordEndedAt } from './callRecordEndedAt';+import type { CallRecordParticipant } from './callRecordParticipant';+import type { CallRecordTranscriptSegment } from './callRecordTranscriptSegment';++/**+ * Full record of a call, unifying rows from `calls` (active) and+`call_records` (archived) into a single response shape.+ */+export interface CallRecord {+ /** The call identifier. */+ callId: string;+ /** The channel this call belongs to. */+ channelId: string;+ /** User who created the call. */+ createdBy: string;+ /** Call duration in milliseconds (None if still active). */+ durationMs?: CallRecordDurationMs;+ /** Recording egress ID, if any. */+ egressId?: CallRecordEgressId;+ /** When the call ended (None if still active). */+ endedAt?: CallRecordEndedAt;+ /** Whether the call is currently active (from `calls` table). */+ isActive: boolean;+ /** Participants (both active and historic). */+ participants: CallRecordParticipant[];+ /** The RTC room name. */+ roomName: string;+ /** When the call started (created_at for active, started_at for archived). */+ startedAt: string;+ /** Transcript segments ordered by `sequence_num`. */+ transcript: CallRecordTranscriptSegment[];+}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordDurationMs.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordDurationMs.tsnew file mode 100644index 0000000000..ece01314cc--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordDurationMs.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Call duration in milliseconds (None if still active).+ */+export type CallRecordDurationMs = number | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordEgressId.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordEgressId.tsnew file mode 100644index 0000000000..60813ec042--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordEgressId.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Recording egress ID, if any.+ */+export type CallRecordEgressId = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordEndedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordEndedAt.tsnew file mode 100644index 0000000000..4987aeafca--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordEndedAt.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * When the call ended (None if still active).+ */+export type CallRecordEndedAt = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordParticipant.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordParticipant.tsnew file mode 100644index 0000000000..f17cf246e2--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordParticipant.ts@@ -0,0 +1,19 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { CallRecordParticipantLeftAt } from './callRecordParticipantLeftAt';++/**+ * A participant as returned in a [`CallRecord`] (historic — includes `left_at`).+ */+export interface CallRecordParticipant {+ /** When the user joined the call. */+ joinedAt: string;+ /** When the user left (None if still in an active call). */+ leftAt?: CallRecordParticipantLeftAt;+ /** The user id. */+ userId: string;+}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordParticipantLeftAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordParticipantLeftAt.tsnew file mode 100644index 0000000000..4ea89ec70d--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordParticipantLeftAt.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * When the user left (None if still in an active call).+ */+export type CallRecordParticipantLeftAt = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegment.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegment.tsnew file mode 100644index 0000000000..b2fd007862--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegment.ts@@ -0,0 +1,26 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { CallRecordTranscriptSegmentEndedAt } from './callRecordTranscriptSegmentEndedAt';+import type { CallRecordTranscriptSegmentSegmentId } from './callRecordTranscriptSegmentSegmentId';++/**+ * A transcript segment as returned in a [`CallRecord`].+ */+export interface CallRecordTranscriptSegment {+ /** The transcribed text content. */+ content: string;+ /** When the speaker stopped (if known). */+ endedAt?: CallRecordTranscriptSegmentEndedAt;+ /** LiveKit segment ID (nullable for archived records). */+ segmentId?: CallRecordTranscriptSegmentSegmentId;+ /** Ordering within the call. */+ sequenceNum: number;+ /** The speaker's user ID. */+ speakerId: string;+ /** When the speaker started this segment. */+ startedAt: string;+}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegmentEndedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegmentEndedAt.tsnew file mode 100644index 0000000000..0f237cdd79--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegmentEndedAt.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * When the speaker stopped (if known).+ */+export type CallRecordTranscriptSegmentEndedAt = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegmentSegmentId.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegmentSegmentId.tsnew file mode 100644index 0000000000..c59da9bd69--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordTranscriptSegmentSegmentId.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * LiveKit segment ID (nullable for archived records).+ */+export type CallRecordTranscriptSegmentSegmentId = string | null;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.tsindex 3f1432ebe4..46310fdde8 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@@ -77,6 +77,15 @@ export * from './basicDocumentType';export * from './basicDocumentUpdatedAt';export * from './bomPart';export * from './callActiveResponse';+export * from './callRecord';+export * from './callRecordDurationMs';+export * from './callRecordEgressId';+export * from './callRecordEndedAt';+export * from './callRecordParticipant';+export * from './callRecordParticipantLeftAt';+export * from './callRecordTranscriptSegment';+export * from './callRecordTranscriptSegmentEndedAt';+export * from './callRecordTranscriptSegmentSegmentId';export * from './callTokenResponse';export * from './channel';export * from './channelFilters';diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex 014684f0dd..9510ef631d 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -810,6 +810,95 @@ export const createCommentResponse = zod}));+/**+ * Returns the full [`CallRecord`] (metadata + participants + transcript)+for a call identified by its own id. Covers both active and archived calls.+Access is validated via channel membership (MemberParticipantRole).+ * @summary Handler for `GET /call/record/{call_id}`.+ */+export const getCallRecordParams = zod.object({+ call_id: zod.string().uuid().describe('Call ID'),+});++export const getCallRecordResponse = zod+ .object({+ callId: zod.string().uuid().describe('The call identifier.'),+ channelId: zod+ .string()+ .uuid()+ .describe('The channel this call belongs to.'),+ createdBy: zod.string().describe('User who created the call.'),+ durationMs: zod+ .number()+ .nullish()+ .describe('Call duration in milliseconds (None if still active).'),+ egressId: zod.string().nullish().describe('Recording egress ID, if any.'),+ endedAt: zod+ .string()+ .datetime({})+ .nullish()+ .describe('When the call ended (None if still active).'),+ isActive: zod+ .boolean()+ .describe('Whether the call is currently active (from `calls` table).'),+ participants: zod+ .array(+ zod+ .object({+ joinedAt: zod+ .string()+ .datetime({})+ .describe('When the user joined the call.'),+ leftAt: zod+ .string()+ .datetime({})+ .nullish()+ .describe(+ 'When the user left (None if still in an active call).'+ ),+ userId: zod.string().describe('The user id.'),+ })+ .describe(+ 'A participant as returned in a [`CallRecord`] (historic — includes `left_at`).'+ )+ )+ .describe('Participants (both active and historic).'),+ roomName: zod.string().describe('The RTC room name.'),+ startedAt: zod+ .string()+ .datetime({})+ .describe(+ 'When the call started (created_at for active, started_at for archived).'+ ),+ transcript: zod+ .array(+ zod+ .object({+ content: zod.string().describe('The transcribed text content.'),+ endedAt: zod+ .string()+ .datetime({})+ .nullish()+ .describe('When the speaker stopped (if known).'),+ segmentId: zod+ .string()+ .nullish()+ .describe('LiveKit segment ID (nullable for archived records).'),+ sequenceNum: zod.number().describe('Ordering within the call.'),+ speakerId: zod.string().describe("The speaker's user ID."),+ startedAt: zod+ .string()+ .datetime({})+ .describe('When the speaker started this segment.'),+ })+ .describe('A transcript segment as returned in a [`CallRecord`].')+ )+ .describe('Transcript segments ordered by `sequence_num`.'),+ })+ .describe(+ 'Full record of a call, unifying rows from `calls` (active) and\n`call_records` (archived) into a single response shape.'+ );+/*** 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.jsonindex 8d59645c81..808ca97162 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -594,6 +594,68 @@}}},+ "/call/record/{call_id}": {+ "get": {+ "tags": ["call::inbound::axum_router"],+ "summary": "Handler for `GET /call/record/{call_id}`.",+ "description": "Returns the full [`CallRecord`] (metadata + participants + transcript)\nfor a call identified by its own id. Covers both active and archived calls.\nAccess is validated via channel membership (MemberParticipantRole).",+ "operationId": "get_call_record",+ "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/CallRecord"+ }+ }+ }+ },+ "401": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ },+ "404": {+ "description": "",+ "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"],@@ -5773,6 +5835,132 @@}}},+ "CallRecord": {+ "type": "object",+ "description": "Full record of a call, unifying rows from `calls` (active) and\n`call_records` (archived) into a single response shape.",+ "required": [+ "callId",+ "channelId",+ "roomName",+ "createdBy",+ "startedAt",+ "isActive",+ "participants",+ "transcript"+ ],+ "properties": {+ "callId": {+ "type": "string",+ "format": "uuid",+ "description": "The call identifier."+ },+ "channelId": {+ "type": "string",+ "format": "uuid",+ "description": "The channel this call belongs to."+ },+ "createdBy": {+ "type": "string",+ "description": "User who created the call."+ },+ "durationMs": {+ "type": ["integer", "null"],+ "format": "int64",+ "description": "Call duration in milliseconds (None if still active)."+ },+ "egressId": {+ "type": ["string", "null"],+ "description": "Recording egress ID, if any."+ },+ "endedAt": {+ "type": ["string", "null"],+ "format": "date-time",+ "description": "When the call ended (None if still active)."+ },+ "isActive": {+ "type": "boolean",+ "description": "Whether the call is currently active (from `calls` table)."+ },+ "participants": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/CallRecordParticipant"+ },+ "description": "Participants (both active and historic)."+ },+ "roomName": {+ "type": "string",+ "description": "The RTC room name."+ },+ "startedAt": {+ "type": "string",+ "format": "date-time",+ "description": "When the call started (created_at for active, started_at for archived)."+ },+ "transcript": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/CallRecordTranscriptSegment"+ },+ "description": "Transcript segments ordered by `sequence_num`."+ }+ }+ },+ "CallRecordParticipant": {+ "type": "object",+ "description": "A participant as returned in a [`CallRecord`] (historic — includes `left_at`).",+ "required": ["userId", "joinedAt"],+ "properties": {+ "joinedAt": {+ "type": "string",+ "format": "date-time",+ "description": "When the user joined the call."+ },+ "leftAt": {+ "type": ["string", "null"],+ "format": "date-time",+ "description": "When the user left (None if still in an active call)."+ },+ "userId": {+ "type": "string",+ "description": "The user id."+ }+ }+ },+ "CallRecordTranscriptSegment": {+ "type": "object",+ "description": "A transcript segment as returned in a [`CallRecord`].",+ "required": ["speakerId", "content", "startedAt", "sequenceNum"],+ "properties": {+ "content": {+ "type": "string",+ "description": "The transcribed text content."+ },+ "endedAt": {+ "type": ["string", "null"],+ "format": "date-time",+ "description": "When the speaker stopped (if known)."+ },+ "segmentId": {+ "type": ["string", "null"],+ "description": "LiveKit segment ID (nullable for archived records)."+ },+ "sequenceNum": {+ "type": "integer",+ "format": "int32",+ "description": "Ordering within the call."+ },+ "speakerId": {+ "type": "string",+ "description": "The speaker's user ID."+ },+ "startedAt": {+ "type": "string",+ "format": "date-time",+ "description": "When the speaker started this segment."+ }+ }+ },"CallTokenResponse": {"type": "object","description": "Response returned when creating or joining a call.",diff --git a/rust/cloud-storage/call/.sqlx/query-10b3ac43bb525d0d54de6c42289ed199b07431041f53b39f733746304bcf50b7.json b/rust/cloud-storage/call/.sqlx/query-10b3ac43bb525d0d54de6c42289ed199b07431041f53b39f733746304bcf50b7.jsonnew file mode 100644index 0000000000..081e733a50--- /dev/null+++ b/rust/cloud-storage/call/.sqlx/query-10b3ac43bb525d0d54de6c42289ed199b07431041f53b39f733746304bcf50b7.json@@ -0,0 +1,52 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT id, channel_id, room_name, created_by, created_at, egress_id\n FROM calls\n WHERE id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "channel_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 2,+ "name": "room_name",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "created_by",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "egress_id",+ "type_info": "Text"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ false,+ true+ ]+ },+ "hash": "10b3ac43bb525d0d54de6c42289ed199b07431041f53b39f733746304bcf50b7"+}diff --git a/rust/cloud-storage/call/.sqlx/query-1ffb3c556caf3fe25d6f69bbeeca0a39d1e5a6fadc9170a2d863fee8fbfb0939.json b/rust/cloud-storage/call/.sqlx/query-1ffb3c556caf3fe25d6f69bbeeca0a39d1e5a6fadc9170a2d863fee8fbfb0939.jsonnew file mode 100644index 0000000000..0101701448--- /dev/null+++ b/rust/cloud-storage/call/.sqlx/query-1ffb3c556caf3fe25d6f69bbeeca0a39d1e5a6fadc9170a2d863fee8fbfb0939.json@@ -0,0 +1,34 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT user_id, joined_at, left_at\n FROM call_record_participants\n WHERE call_record_id = $1\n ORDER BY joined_at ASC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "joined_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 2,+ "name": "left_at",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ true+ ]+ },+ "hash": "1ffb3c556caf3fe25d6f69bbeeca0a39d1e5a6fadc9170a2d863fee8fbfb0939"+}diff --git a/rust/cloud-storage/call/.sqlx/query-38d8954ab4b43aa67742a32d78af64cfaf2c5620a534753cc358602d626693c1.json b/rust/cloud-storage/call/.sqlx/query-38d8954ab4b43aa67742a32d78af64cfaf2c5620a534753cc358602d626693c1.jsonnew file mode 100644index 0000000000..9073b27116--- /dev/null+++ b/rust/cloud-storage/call/.sqlx/query-38d8954ab4b43aa67742a32d78af64cfaf2c5620a534753cc358602d626693c1.json@@ -0,0 +1,34 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT user_id, joined_at, left_at\n FROM call_participants\n WHERE call_id = $1\n ORDER BY joined_at ASC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "joined_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 2,+ "name": "left_at",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ true+ ]+ },+ "hash": "38d8954ab4b43aa67742a32d78af64cfaf2c5620a534753cc358602d626693c1"+}diff --git a/rust/cloud-storage/call/.sqlx/query-a33089d525147261468bbf9c4522b251d3ddd6d499f77fb4e102787111195cee.json b/rust/cloud-storage/call/.sqlx/query-a33089d525147261468bbf9c4522b251d3ddd6d499f77fb4e102787111195cee.jsonnew file mode 100644index 0000000000..54a1434464--- /dev/null+++ b/rust/cloud-storage/call/.sqlx/query-a33089d525147261468bbf9c4522b251d3ddd6d499f77fb4e102787111195cee.json@@ -0,0 +1,52 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT segment_id, speaker_id, content, started_at, ended_at, sequence_num\n FROM call_record_transcripts\n WHERE call_record_id = $1\n ORDER BY sequence_num ASC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "segment_id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "speaker_id",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "content",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "started_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 4,+ "name": "ended_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "sequence_num",+ "type_info": "Int4"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ true,+ false,+ false,+ false,+ true,+ false+ ]+ },+ "hash": "a33089d525147261468bbf9c4522b251d3ddd6d499f77fb4e102787111195cee"+}diff --git a/rust/cloud-storage/call/.sqlx/query-a6882145e34b9196f175874ed47a08b4739179533ed3369d181ce07b3d2f5d80.json b/rust/cloud-storage/call/.sqlx/query-a6882145e34b9196f175874ed47a08b4739179533ed3369d181ce07b3d2f5d80.jsonnew file mode 100644index 0000000000..776100dc7a--- /dev/null+++ b/rust/cloud-storage/call/.sqlx/query-a6882145e34b9196f175874ed47a08b4739179533ed3369d181ce07b3d2f5d80.json@@ -0,0 +1,52 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT segment_id, speaker_id, content, started_at, ended_at, sequence_num\n FROM call_transcripts\n WHERE call_id = $1\n ORDER BY sequence_num ASC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "segment_id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "speaker_id",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "content",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "started_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 4,+ "name": "ended_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "sequence_num",+ "type_info": "Int4"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ true,+ false+ ]+ },+ "hash": "a6882145e34b9196f175874ed47a08b4739179533ed3369d181ce07b3d2f5d80"+}diff --git a/rust/cloud-storage/call/.sqlx/query-ca2128680337c450ace5d58cbbf31cc419b098d4396b83e0ef1e8798e4f83050.json b/rust/cloud-storage/call/.sqlx/query-ca2128680337c450ace5d58cbbf31cc419b098d4396b83e0ef1e8798e4f83050.jsonnew file mode 100644index 0000000000..d645c4a142--- /dev/null+++ b/rust/cloud-storage/call/.sqlx/query-ca2128680337c450ace5d58cbbf31cc419b098d4396b83e0ef1e8798e4f83050.json@@ -0,0 +1,64 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id\n FROM call_records\n WHERE id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "channel_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 2,+ "name": "room_name",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "created_by",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "started_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "ended_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 6,+ "name": "duration_ms",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "egress_id",+ "type_info": "Text"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ false,+ false,+ false,+ true+ ]+ },+ "hash": "ca2128680337c450ace5d58cbbf31cc419b098d4396b83e0ef1e8798e4f83050"+}diff --git a/rust/cloud-storage/call/fixtures/call_repo.sql b/rust/cloud-storage/call/fixtures/call_repo.sqlindex 2dbeb14862..83345a444e 100644--- a/rust/cloud-storage/call/fixtures/call_repo.sql+++ b/rust/cloud-storage/call/fixtures/call_repo.sql@@ -30,3 +30,27 @@ INSERT INTO calls (id, channel_id, room_name, created_by, created_at, share_permINSERT INTO call_participants (call_id, user_id, joined_at) VALUES('00000000-0000-0000-0000-0000000ca110', 'macro|[email protected]', '2024-01-01 12:00:00+00'),('00000000-0000-0000-0000-0000000ca110', 'macro|[email protected]', '2024-01-01 12:01:00+00');++-- share permission for the archived call+INSERT INTO "SharePermission" (id, "isPublic", "publicAccessLevel", "createdAt", "updatedAt") VALUES+ ('00000000-0000-0000-0000-00000000sp02', false, NULL, '2024-01-01 00:00:00+00', '2024-01-01 00:00:00+00');++INSERT INTO "ChannelSharePermission" (share_permission_id, channel_id, access_level) VALUES+ ('00000000-0000-0000-0000-00000000sp02', '00000000-0000-0000-0000-000000000c01', 'view');++-- archived call record in ch1 (id = CALL_ARCHIVED)+INSERT INTO call_records (id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, share_permission_id) VALUES+ ('00000000-0000-0000-0000-0000000ca2ed', '00000000-0000-0000-0000-000000000c01',+ '00000000-0000-0000-0000-000000000c01', 'macro|[email protected]',+ '2024-01-01 10:00:00+00', '2024-01-01 10:05:00+00', 300000, 'egress-arch-1',+ '00000000-0000-0000-0000-00000000sp02');++INSERT INTO call_record_participants (call_record_id, user_id, joined_at, left_at) VALUES+ ('00000000-0000-0000-0000-0000000ca2ed', 'macro|[email protected]', '2024-01-01 10:00:00+00', '2024-01-01 10:05:00+00'),+ ('00000000-0000-0000-0000-0000000ca2ed', 'macro|[email protected]', '2024-01-01 10:01:00+00', '2024-01-01 10:04:30+00');++INSERT INTO call_record_transcripts (call_record_id, segment_id, speaker_id, content, started_at, ended_at, sequence_num) VALUES+ ('00000000-0000-0000-0000-0000000ca2ed', 'seg-arch-1', 'macro|[email protected]', 'archived hello',+ '2024-01-01 10:00:05+00', '2024-01-01 10:00:07+00', 1),+ ('00000000-0000-0000-0000-0000000ca2ed', 'seg-arch-2', 'macro|[email protected]', 'archived reply',+ '2024-01-01 10:00:08+00', '2024-01-01 10:00:10+00', 2);diff --git a/rust/cloud-storage/call/src/domain/models.rs b/rust/cloud-storage/call/src/domain/models.rsindex 69e5d55230..0068d35590 100644--- a/rust/cloud-storage/call/src/domain/models.rs+++ b/rust/cloud-storage/call/src/domain/models.rs@@ -137,6 +137,68 @@ pub struct TranscriptSegmentRequest {pub is_final: bool,}+/// A transcript segment as returned in a [`CallRecord`].+#[derive(Debug, Clone, serde::Serialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+#[serde(rename_all = "camelCase")]+pub struct CallRecordTranscriptSegment {+ /// LiveKit segment ID (nullable for archived records).+ pub segment_id: Option<String>,+ /// The speaker's user ID.+ pub speaker_id: String,+ /// The transcribed text content.+ pub content: String,+ /// When the speaker started this segment.+ pub started_at: DateTime<Utc>,+ /// When the speaker stopped (if known).+ pub ended_at: Option<DateTime<Utc>>,+ /// Ordering within the call.+ pub sequence_num: i32,+}++/// A participant as returned in a [`CallRecord`] (historic — includes `left_at`).+#[derive(Debug, Clone, serde::Serialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+#[serde(rename_all = "camelCase")]+pub struct CallRecordParticipant {+ /// The user id.+ pub user_id: String,+ /// When the user joined the call.+ pub joined_at: DateTime<Utc>,+ /// When the user left (None if still in an active call).+ pub left_at: Option<DateTime<Utc>>,+}++/// Full record of a call, unifying rows from `calls` (active) and+/// `call_records` (archived) into a single response shape.+#[derive(Debug, Clone, serde::Serialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+#[serde(rename_all = "camelCase")]+pub struct CallRecord {+ /// The call identifier.+ pub call_id: Uuid,+ /// The channel this call belongs to.+ pub channel_id: Uuid,+ /// The RTC room name.+ pub room_name: String,+ /// User who created the call.+ pub created_by: String,+ /// When the call started (created_at for active, started_at for archived).+ pub started_at: DateTime<Utc>,+ /// When the call ended (None if still active).+ pub ended_at: Option<DateTime<Utc>>,+ /// Call duration in milliseconds (None if still active).+ pub duration_ms: Option<i64>,+ /// Recording egress ID, if any.+ pub egress_id: Option<String>,+ /// Whether the call is currently active (from `calls` table).+ pub is_active: bool,+ /// Participants (both active and historic).+ pub participants: Vec<CallRecordParticipant>,+ /// Transcript segments ordered by `sequence_num`.+ pub transcript: Vec<CallRecordTranscriptSegment>,+}+/// Errors that can occur during call operations.#[derive(Debug, thiserror::Error)]pub enum CallError {diff --git a/rust/cloud-storage/call/src/domain/ports.rs b/rust/cloud-storage/call/src/domain/ports.rsindex 7f3de59a00..fb249343d4 100644--- a/rust/cloud-storage/call/src/domain/ports.rs+++ b/rust/cloud-storage/call/src/domain/ports.rs@@ -5,12 +5,13 @@use std::fmt::Debug;use std::future::Future;+use entity_access::domain::models::{EntityAccessReceipt, MemberParticipantRole};use macro_user_id::user_id::MacroUserIdStr;use uuid::Uuid;use super::models::{- Call, CallActiveResponse, CallError, CallParticipant, CallTokenResponse, CallWebhookEvent,- EgressS3Config, LeaveCallResponse, TranscriptSegmentRequest,+ Call, CallActiveResponse, CallError, CallParticipant, CallRecord, CallTokenResponse,+ CallWebhookEvent, EgressS3Config, LeaveCallResponse, TranscriptSegmentRequest,};/// Repository port for persisting call state to the database.@@ -130,6 +131,15 @@ pub trait CallRepository: Send + Sync + 'static {&self,user_id: MacroUserIdStr<'a>,) -> impl Future<Output = Result<Option<String>, Self::Err>> + Send;++ /// Fetch a full [`CallRecord`] by call id. Looks in both the active+ /// `calls` table and the archived `call_records` table; returns `None`+ /// if neither has a matching row. The returned record includes the+ /// call's participants and transcript segments.+ fn get_call_record_by_call_id(+ &self,+ call_id: &Uuid,+ ) -> impl Future<Output = Result<Option<CallRecord>, Self::Err>> + Send;}/// RTC client port for interacting with the real-time communication service (e.g., LiveKit).@@ -217,4 +227,14 @@ pub trait CallService: Send + Sync + 'static {channel_id: &Uuid,segment: TranscriptSegmentRequest,) -> impl Future<Output = Result<(), CallError>> + Send;++ /// Fetch the [`CallRecord`] for a call the caller has channel-member access to.+ ///+ /// Authorization is carried in the receipt produced by+ /// `CallAccessLevelExtractor`; the entity on the receipt must be+ /// `EntityType::Call` and its `entity_id` must be the call's UUID.+ fn get_call_record(+ &self,+ receipt: EntityAccessReceipt<MemberParticipantRole>,+ ) -> impl Future<Output = Result<CallRecord, CallError>> + Send;}diff --git a/rust/cloud-storage/call/src/domain/service.rs b/rust/cloud-storage/call/src/domain/service.rsindex 709cd7a803..268ffeff29 100644--- a/rust/cloud-storage/call/src/domain/service.rs+++ b/rust/cloud-storage/call/src/domain/service.rs@@ -1,7 +1,7 @@//! Call service implementation.use connection::domain::ports::ConnectionService;-use entity_access::domain::models::EntityType;+use entity_access::domain::models::{EntityAccessReceipt, EntityType, MemberParticipantRole};use entity_access::domain::ports::EntityAccessService;use macro_user_id::cowlike::CowLike;use macro_user_id::user_id::MacroUserIdStr;@@ -17,8 +17,8 @@ use std::collections::HashSet;use uuid::Uuid;use super::models::{- CallActiveResponse, CallError, CallTokenResponse, EgressS3Config, LeaveCallResponse,- TranscriptSegmentRequest,+ CallActiveResponse, CallError, CallRecord, CallTokenResponse, EgressS3Config,+ LeaveCallResponse, TranscriptSegmentRequest,};use super::ports::{CallRepository, CallRtcClient, CallService};@@ -575,6 +575,28 @@ impl<Ok(())}+ #[tracing::instrument(err, skip(self))]+ async fn get_call_record(+ &self,+ receipt: EntityAccessReceipt<MemberParticipantRole>,+ ) -> Result<CallRecord, CallError> {+ let entity = receipt.entity();+ if entity.entity_type != EntityType::Call {+ return Err(CallError::Internal(anyhow::anyhow!(+ "expected Call entity in receipt, got {:?}",+ entity.entity_type+ )));+ }+ let call_id = Uuid::parse_str(&entity.entity_id)+ .map_err(|_| CallError::Internal(anyhow::anyhow!("invalid call_id in receipt")))?;++ self.repo+ .get_call_record_by_call_id(&call_id)+ .await+ .map_err(|e| CallError::Internal(e.into()))?+ .ok_or_else(|| CallError::NotFound(call_id.to_string()))+ }+#[tracing::instrument(err, skip(self, segment))]async fn ingest_transcript_segment(&self,diff --git a/rust/cloud-storage/call/src/inbound/axum_router.rs b/rust/cloud-storage/call/src/inbound/axum_router.rsindex 4cf133fa54..939e1090f7 100644--- a/rust/cloud-storage/call/src/inbound/axum_router.rs+++ b/rust/cloud-storage/call/src/inbound/axum_router.rs@@ -21,7 +21,8 @@ use entity_access::{domain::models::MemberParticipantRole,domain::ports::EntityAccessService,inbound::axum_extractors::{- CallWithChannelIdAccessLevelExtractor, ChannelAccessLevelExtractor,+ CallAccessLevelExtractor, CallWithChannelIdAccessLevelExtractor,+ ChannelAccessLevelExtractor,},};use model_error_response::ErrorResponse;@@ -29,7 +30,8 @@ use model_user::axum_extractor::MacroUserExtractor;use uuid::Uuid;use crate::domain::models::{- CallActiveResponse, CallError, CallTokenResponse, LeaveCallResponse, TranscriptSegmentRequest,+ CallActiveResponse, CallError, CallRecord, CallTokenResponse, LeaveCallResponse,+ TranscriptSegmentRequest,};use crate::domain::ports::CallService;@@ -74,6 +76,7 @@ impl<S, Svc> FromRef<CallRouterState<S, Svc>> for Arc<Svc> {/// - `GET /{channel_id}` — get or create a call (join existing or start new)/// - `GET /{channel_id}/active` — check if an active call exists/// - `DELETE /{channel_id}` — leave or end a call+/// - `GET /record/{call_id}` — get a full call record (transcript + participants)pub fn call_router<S, Svc, T>(state: CallRouterState<S, Svc>) -> Router<T>whereS: CallService,@@ -89,6 +92,7 @@ where"/{channel_id}/active",get(check_active_call_handler::<S, Svc>),)+ .route("/record/{call_id}", get(get_call_record_handler::<S, Svc>)).with_state(state)}@@ -280,6 +284,37 @@ pub async fn check_active_call_handler<S: CallService, Svc: EntityAccessService>}}+/// Handler for `GET /call/record/{call_id}`.+///+/// Returns the full [`CallRecord`] (metadata + participants + transcript)+/// for a call identified by its own id. Covers both active and archived calls.+/// Access is validated via channel membership (MemberParticipantRole).+#[utoipa::path(+ get,+ operation_id = "get_call_record",+ path = "/call/record/{call_id}",+ params(+ ("call_id" = Uuid, Path, description = "Call ID"),+ ),+ responses(+ (status = 200, body = CallRecord),+ (status = 401, body = ErrorResponse),+ (status = 404, body = ErrorResponse),+ (status = 500, body = ErrorResponse),+ )+)]+#[tracing::instrument(err, skip_all)]+pub async fn get_call_record_handler<S: CallService, Svc: EntityAccessService>(+ State(state): State<CallRouterState<S, Svc>>,+ access: CallAccessLevelExtractor<MemberParticipantRole, Svc>,+) -> Result<Json<CallRecord>, CallError> {+ let record = state+ .service+ .get_call_record(access.entity_access_receipt)+ .await?;+ Ok(Json(record))+}+/// Handler for `DELETE /call/{channel_id}`.#[utoipa::path(delete,diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo.rsindex d26b3e7905..27067fb9a9 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo.rs@@ -11,7 +11,10 @@ use models_permissions::share_permission::channel_share_permission::ChannelShareuse sqlx::PgPool;use uuid::Uuid;-use crate::domain::models::{Call, CallParticipant, TranscriptSegmentRequest};+use crate::domain::models::{+ Call, CallParticipant, CallRecord, CallRecordParticipant, CallRecordTranscriptSegment,+ TranscriptSegmentRequest,+};use crate::domain::ports::CallRepository;/// Postgres implementation of [`CallRepository`].@@ -481,6 +484,164 @@ impl CallRepository for PgCallRepo {Ok(())}+ #[tracing::instrument(err, skip(self))]+ async fn get_call_record_by_call_id(+ &self,+ call_id: &Uuid,+ ) -> Result<Option<CallRecord>, Self::Err> {+ // Use a read-only snapshot-isolation transaction so the call row and its+ // participants/transcripts all reflect the same point in time. Without this,+ // a concurrent `archive_call` can move rows from `calls` -> `call_records`+ // between our SELECTs, leaving us with an "active" call row but empty+ // participants/transcript (or vice versa). REPEATABLE READ gives a stable+ // snapshot; READ ONLY avoids blocking writers.+ let mut tx = self.pool.begin().await?;+ sqlx::query("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY")+ .execute(&mut *tx)+ .await?;++ // Try active `calls` first.+ if let Some(active) = sqlx::query!(+ r#"+ SELECT id, channel_id, room_name, created_by, created_at, egress_id+ FROM calls+ WHERE id = $1+ "#,+ call_id,+ )+ .fetch_optional(&mut *tx)+ .await?+ {+ let participants = sqlx::query!(+ r#"+ SELECT user_id, joined_at, left_at+ FROM call_participants+ WHERE call_id = $1+ ORDER BY joined_at ASC+ "#,+ call_id,+ )+ .fetch_all(&mut *tx)+ .await?+ .into_iter()+ .map(|row| CallRecordParticipant {+ user_id: row.user_id,+ joined_at: row.joined_at,+ left_at: row.left_at,+ })+ .collect();++ let transcript = sqlx::query!(+ r#"+ SELECT segment_id, speaker_id, content, started_at, ended_at, sequence_num+ FROM call_transcripts+ WHERE call_id = $1+ ORDER BY sequence_num ASC+ "#,+ call_id,+ )+ .fetch_all(&mut *tx)+ .await?+ .into_iter()+ .map(|row| CallRecordTranscriptSegment {+ segment_id: Some(row.segment_id),+ speaker_id: row.speaker_id,+ content: row.content,+ started_at: row.started_at,+ ended_at: row.ended_at,+ sequence_num: row.sequence_num,+ })+ .collect();++ tx.commit().await?;+ return Ok(Some(CallRecord {+ call_id: active.id,+ channel_id: active.channel_id,+ room_name: active.room_name,+ created_by: active.created_by,+ started_at: active.created_at,+ ended_at: None,+ duration_ms: None,+ egress_id: active.egress_id,+ is_active: true,+ participants,+ transcript,+ }));+ }++ // Fall back to archived `call_records`.+ let Some(archived) = sqlx::query!(+ r#"+ SELECT id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id+ FROM call_records+ WHERE id = $1+ "#,+ call_id,+ )+ .fetch_optional(&mut *tx)+ .await?+ else {+ tx.commit().await?;+ return Ok(None);+ };++ let participants = sqlx::query!(+ r#"+ SELECT user_id, joined_at, left_at+ FROM call_record_participants+ WHERE call_record_id = $1+ ORDER BY joined_at ASC+ "#,+ call_id,+ )+ .fetch_all(&mut *tx)+ .await?+ .into_iter()+ .map(|row| CallRecordParticipant {+ user_id: row.user_id,+ joined_at: row.joined_at,+ left_at: row.left_at,+ })+ .collect();++ let transcript = sqlx::query!(+ r#"+ SELECT segment_id, speaker_id, content, started_at, ended_at, sequence_num+ FROM call_record_transcripts+ WHERE call_record_id = $1+ ORDER BY sequence_num ASC+ "#,+ call_id,+ )+ .fetch_all(&mut *tx)+ .await?+ .into_iter()+ .map(|row| CallRecordTranscriptSegment {+ segment_id: row.segment_id,+ speaker_id: row.speaker_id,+ content: row.content,+ started_at: row.started_at,+ ended_at: row.ended_at,+ sequence_num: row.sequence_num,+ })+ .collect();++ tx.commit().await?;+ Ok(Some(CallRecord {+ call_id: archived.id,+ channel_id: archived.channel_id,+ room_name: archived.room_name,+ created_by: archived.created_by,+ started_at: archived.started_at,+ ended_at: Some(archived.ended_at),+ duration_ms: Some(archived.duration_ms),+ egress_id: archived.egress_id,+ is_active: false,+ participants,+ transcript,+ }))+ }+#[tracing::instrument(err, skip(self))]async fn get_user_profile_picture<'a>(&self,diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rsindex 33c4253aea..923c292059 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs@@ -12,6 +12,7 @@ use uuid::Uuid;const CH1: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000c01);const CH2: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000c02);const CALL1: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_0000000ca110);+const CALL_ARCHIVED: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_0000000ca2ed);static USER_A: LazyLock<MacroUserIdStr<'static>> =LazyLock::new(|| MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap());static USER_B: LazyLock<MacroUserIdStr<'static>> =@@ -500,3 +501,111 @@ async fn archive_call_copies_transcripts(pool: Pool<Postgres>) -> anyhow::ResultOk(())}++// -- get_call_record_by_call_id ----------------------------------------------++#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn get_call_record_returns_active_call(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let repo = repo(pool);+ let now = Utc::now();++ // Ingest two transcript segments into the active call.+ repo.create_transcript_segment(+ &CALL1,+ &TranscriptSegmentRequest {+ segment_id: "seg-live-1".to_string(),+ speaker_id: USER_A.to_string(),+ content: "hello there".to_string(),+ started_at: now,+ ended_at: Some(now),+ is_final: true,+ },+ )+ .await?;+ repo.create_transcript_segment(+ &CALL1,+ &TranscriptSegmentRequest {+ segment_id: "seg-live-2".to_string(),+ speaker_id: USER_B.to_string(),+ content: "general kenobi".to_string(),+ started_at: now,+ ended_at: Some(now),+ is_final: true,+ },+ )+ .await?;++ let record = repo+ .get_call_record_by_call_id(&CALL1)+ .await?+ .expect("active call should be found");++ assert_eq!(record.call_id, CALL1);+ assert_eq!(record.channel_id, CH1);+ assert!(record.is_active);+ assert!(record.ended_at.is_none());+ assert!(record.duration_ms.is_none());++ // Participants from fixture.+ let user_ids: Vec<&str> = record+ .participants+ .iter()+ .map(|p| p.user_id.as_str())+ .collect();+ assert_eq!(user_ids, vec![USER_A.as_ref(), USER_B.as_ref()]);++ // Transcripts ordered by sequence_num.+ assert_eq!(record.transcript.len(), 2);+ assert_eq!(record.transcript[0].sequence_num, 1);+ assert_eq!(record.transcript[0].content, "hello there");+ assert_eq!(+ record.transcript[0].segment_id.as_deref(),+ Some("seg-live-1")+ );+ assert_eq!(record.transcript[1].sequence_num, 2);+ assert_eq!(record.transcript[1].content, "general kenobi");+ Ok(())+}++#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn get_call_record_returns_archived_call(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let repo = repo(pool);+ let record = repo+ .get_call_record_by_call_id(&CALL_ARCHIVED)+ .await?+ .expect("archived call should be found");++ assert_eq!(record.call_id, CALL_ARCHIVED);+ assert_eq!(record.channel_id, CH1);+ assert!(!record.is_active);+ assert!(record.ended_at.is_some());+ assert_eq!(record.duration_ms, Some(300_000));+ assert_eq!(record.egress_id.as_deref(), Some("egress-arch-1"));++ // Participants from archived fixture (both have left_at).+ assert_eq!(record.participants.len(), 2);+ assert!(record.participants.iter().all(|p| p.left_at.is_some()));++ // Transcripts ordered by sequence_num.+ assert_eq!(record.transcript.len(), 2);+ assert_eq!(record.transcript[0].content, "archived hello");+ assert_eq!(record.transcript[1].content, "archived reply");+ Ok(())+}++#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn get_call_record_returns_none_for_unknown(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let repo = repo(pool);+ let record = repo.get_call_record_by_call_id(&Uuid::now_v7()).await?;+ assert!(record.is_none());+ Ok(())+}diff --git a/rust/cloud-storage/document_storage_service/src/api/swagger.rs b/rust/cloud-storage/document_storage_service/src/api/swagger.rsindex 1d7ab3de49..7a2299ffa2 100644--- a/rust/cloud-storage/document_storage_service/src/api/swagger.rs+++ b/rust/cloud-storage/document_storage_service/src/api/swagger.rs@@ -194,6 +194,7 @@ use utoipa::OpenApi;call::inbound::axum_router::get_or_create_call_handler,call::inbound::axum_router::check_active_call_handler,call::inbound::axum_router::leave_or_end_call_handler,+ call::inbound::axum_router::get_call_record_handler,call::inbound::axum_router::webhook_handler,call::inbound::axum_router::transcript_handler,@@ -339,6 +340,9 @@ use utoipa::OpenApi;call::domain::models::CallActiveResponse,call::domain::models::LeaveCallResponse,call::domain::models::TranscriptSegmentRequest,+ call::domain::models::CallRecord,+ call::domain::models::CallRecordParticipant,+ call::domain::models::CallRecordTranscriptSegment,DocumentSubType,diff --git a/rust/cloud-storage/entity_access/src/domain/service.rs b/rust/cloud-storage/entity_access/src/domain/service.rsindex 97de4d272a..4f8c7da221 100644--- a/rust/cloud-storage/entity_access/src/domain/service.rs+++ b/rust/cloud-storage/entity_access/src/domain/service.rs@@ -74,6 +74,22 @@ whereOk(None)}}++ /// Resolve a call id string to the channel id that owns it.+ ///+ /// Looks up both the active `calls` table and the archived `call_records`+ /// table. Returns `NotFound` if neither has a matching row, or+ /// `BadRequest` if the id is not a valid UUID.+ async fn resolve_call_channel_id(&self, call_id: &str) -> Result<Uuid, AccessError> {+ let call_uuid = Uuid::from_str(call_id)+ .map_err(|_| AccessError::BadRequest("Invalid call ID format"))?;+ let info = self+ .repo+ .get_call_channel(&call_uuid)+ .await?+ .ok_or(AccessError::NotFound("Call not found"))?;+ Ok(info.channel_id)+ }}impl<R> EntityAccessService for EntityAccessServiceImpl<R>@@ -123,7 +139,13 @@ where.await}EntityType::Channel => self.get_channel_access(entity_id, user_id).await,- // These entity types don't have access checks implemented yet+ // Call access is inherited from the call's channel.+ EntityType::Call => {+ let channel_uuid = self.resolve_call_channel_id(entity_id).await?;+ self.get_channel_access(&channel_uuid.to_string(), user_id)+ .await+ }+ // These entity types don't have access checks implemented yet.EntityType::Team | EntityType::User => Ok(None),}}@@ -199,6 +221,19 @@ whereChannelRoleResult::NotFound => Err(AccessError::NotFound("Channel not found")),}}+ EntityType::Call => {+ // Call permission is the caller's role on the call's channel.+ let channel_uuid = self.resolve_call_channel_id(entity_id).await?;+ match self+ .repo+ .get_channel_role(&channel_uuid, user_id, user_org_id)+ .await?+ {+ ChannelRoleResult::Role(role) => Ok(EntityPermission::ChannelRole { role }),+ ChannelRoleResult::NoAccess => Err(AccessError::Unauthorized),+ ChannelRoleResult::NotFound => Err(AccessError::NotFound("Channel not found")),+ }+ }_ => Err(AccessError::BadRequest("Unsupported entity type")),}}@@ -220,6 +255,11 @@ where})?;self.repo.get_channel_users(&channel_id).await}+ EntityType::Call => {+ // Participants of a call are the members of its channel.+ let channel_id = self.resolve_call_channel_id(entity_id).await?;+ self.repo.get_channel_users(&channel_id).await+ }_ => Err(AccessError::BadRequest("get_users_by_entity does not support this entity type",)),diff --git a/rust/cloud-storage/entity_access/src/inbound/axum_extractors/call.rs b/rust/cloud-storage/entity_access/src/inbound/axum_extractors/call.rsindex 59a6e93375..188f69f984 100644--- a/rust/cloud-storage/entity_access/src/inbound/axum_extractors/call.rs+++ b/rust/cloud-storage/entity_access/src/inbound/axum_extractors/call.rs@@ -101,8 +101,8 @@ wherereturn Ok(Self {entity_access_receipt: EntityAccessReceipt {entity: Entity {- entity_id: call_info.channel_id.to_string(),- entity_type: EntityType::Channel,+ entity_id: call_id,+ entity_type: EntityType::Call,},auth: EntityAccessAuth::Internal,entity_permission: EntityPermission::ChannelRole {@@ -140,8 +140,8 @@ whereOk(Self {entity_access_receipt: EntityAccessReceipt {entity: Entity {- entity_id: channel_id_str,- entity_type: EntityType::Channel,+ entity_id: call_id,+ entity_type: EntityType::Call,},auth: EntityAccessAuth::Authenticated(macro_user_id),entity_permission: permission,diff --git a/rust/cloud-storage/model-entity/src/lib.rs b/rust/cloud-storage/model-entity/src/lib.rsindex dedf36311b..82f9f98025 100644--- a/rust/cloud-storage/model-entity/src/lib.rs+++ b/rust/cloud-storage/model-entity/src/lib.rs@@ -45,6 +45,8 @@ pub enum EntityType {EmailThread,/// The entity is a teamTeam,+ /// The entity is a voice/video call+ Call,}impl EntityType {@@ -59,6 +61,9 @@ impl EntityType {EntityType::Document => true,EntityType::Project => true,EntityType::EmailThread => true,+ // Calls are handled by entity_access by resolving through the call's+ // owning channel (access is inherited from channel membership).+ EntityType::Call => true,}}/// provide an entity string slice to upgrade this type into an [Entity]