fix: support transcoding for attachment transactions (#9775)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2025-09-04 16:15:00 +07:00
committed by GitHub
parent fd147586b7
commit db9c52a1bd
2 changed files with 16 additions and 11 deletions
+4 -4
View File
@@ -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 }
}
]
}
+12 -7
View File
@@ -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<Event>,
producer: PlatformQueueProducer<VideoTranscodeRequest>
): Promise<void> {
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)
}