diff --git a/pods/media/src/client.ts b/pods/media/src/client.ts index f81684d9cf..268cca4c83 100644 --- a/pods/media/src/client.ts +++ b/pods/media/src/client.ts @@ -131,16 +131,16 @@ export class WorkspaceClient { const txOps = new TxOperations(this.client, core.account.System) await txOps.domainRequest('communication' as OperationDomain, { event: { - type: MessageEventType.BlobPatch, + type: MessageEventType.AttachmentPatch, cardId: result.source.cardId, messageId: result.source.messageId, operations: [ { opcode: 'update', - blobs: [ + attachments: [ { - blobId: result.blobId, - metadata + id: result.blobId, + params: { metadata } } ] } diff --git a/pods/media/src/handler.ts b/pods/media/src/handler.ts index f6a29aeba2..137e5000a7 100644 --- a/pods/media/src/handler.ts +++ b/pods/media/src/handler.ts @@ -15,6 +15,7 @@ import attachment, { type Attachment } from '@hcengineering/attachment' import { Event, MessageEventType } from '@hcengineering/communication-sdk-types' +import { BlobAttachment } from '@hcengineering/communication-types' import drive, { type FileVersion } from '@hcengineering/drive' import core, { type Blob, @@ -94,22 +95,26 @@ async function handleCommunicationTx ( tx: TxDomainEvent, producer: PlatformQueueProducer ): Promise { - if (tx.domain === COMMUNICATION && tx.event.type === MessageEventType.BlobPatch) { + if (tx.domain === COMMUNICATION && tx.event.type === MessageEventType.AttachmentPatch) { const event = tx.event const source: BlobSource = { source: BlobSourceType.Message, cardId: event.cardId, messageId: event.messageId } - const blobs = event.operations - .filter((it) => it.opcode === 'attach' || it.opcode === 'set') - .flatMap((it) => it.blobs) - const messages: VideoTranscodeRequest[] = blobs.map(({ blobId, mimeType }) => ({ + + const attachments = event.operations + .filter((it) => it.opcode === 'add' || it.opcode === 'set') + .flatMap((it) => it.attachments) + .filter((it): it is BlobAttachment => 'blobId' in it.params) + + const messages: VideoTranscodeRequest[] = attachments.map(({ params }) => ({ workspaceUuid, - blobId, - contentType: mimeType, + blobId: params.blobId, + contentType: params.mimeType, source })) + if (messages.length > 0) { await producer.send(ctx, workspaceUuid, messages) }