From eab8a40ad4aa43aaf0c0204a0b119f24953a2f56 Mon Sep 17 00:00:00 2001 From: Kristina Fefelova Date: Thu, 2 Oct 2025 11:38:32 +0400 Subject: [PATCH] Attach poll card to message and replace generateUuid Signed-off-by: Kristina Fefelova --- common/config/rush/pnpm-lock.yaml | 4 +++- communication | 2 +- packages/presentation/src/communication.ts | 8 ++++---- plugins/communication-resources/src/poll.ts | 4 +++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 1490088f3b3..04463e3d385 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -4562,7 +4562,7 @@ packages: version: 0.0.0 '@rush-temp/communication-server@file:projects/communication-server.tgz': - resolution: {integrity: sha512-HfKzdbndaS3opK1inqcTOrVnKvU7PS2asLmKuR4JHooiTTvFFCHcXXYO++t1QmdGmankZRn3Qsq59CIt/UPgsA==, tarball: file:projects/communication-server.tgz} + resolution: {integrity: sha512-NqgsYYbjEFDp0w3T3g9pjDaYwAfMfqE5PkZoZ2dY/YTudJcRfnYV4uHuyIDKw6HceDKfLZSd3zScMXjR5m3uNA==, tarball: file:projects/communication-server.tgz} version: 0.0.0 '@rush-temp/communication-shared@file:projects/communication-shared.tgz': @@ -19177,6 +19177,7 @@ snapshots: '@rush-temp/communication-server@file:projects/communication-server.tgz(@types/node@22.15.29)(ts-node@10.9.2(@swc/core@1.13.5)(@types/node@22.15.29)(typescript@5.8.3))': dependencies: + '@types/uuid': 8.3.4 '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.56.0)(typescript@5.8.3))(eslint@8.56.0)(typescript@5.8.3) '@typescript-eslint/parser': 6.21.0(eslint@8.56.0)(typescript@5.8.3) esbuild: 0.25.9 @@ -19189,6 +19190,7 @@ snapshots: jest: 29.7.0(@types/node@22.15.29)(ts-node@10.9.2(@swc/core@1.13.5)(@types/node@22.15.29)(typescript@5.8.3)) prettier: 3.2.5 typescript: 5.8.3 + uuid: 8.3.2 zod: 3.24.2 transitivePeerDependencies: - '@types/node' diff --git a/communication b/communication index 961934e8dd2..bbccecb9dbb 160000 --- a/communication +++ b/communication @@ -1 +1 @@ -Subproject commit 961934e8dd2b9df0b3ca94650e370ec900436e32 +Subproject commit bbccecb9dbb90802781d37e1f167021ce3b88c0d diff --git a/packages/presentation/src/communication.ts b/packages/presentation/src/communication.ts index ad1d309d156..d60ad8f6c5c 100644 --- a/packages/presentation/src/communication.ts +++ b/packages/presentation/src/communication.ts @@ -74,8 +74,7 @@ import core, { SocialIdType, type Tx, type TxDomainEvent, - AccountRole, - generateUuid + AccountRole } from '@hcengineering/core' import { onDestroy } from 'svelte' import { addNotification, NotificationSeverity, languageStore } from '@hcengineering/ui' @@ -83,6 +82,7 @@ import { getMetadata, translate } from '@hcengineering/platform' import view from '@hcengineering/view' import { get } from 'svelte/store' import { getClient as getHulylakeClient } from '@hcengineering/hulylake-client' +import { v4 as uuid } from 'uuid' import { getCurrentWorkspaceUuid } from './file' import { addTxListener, removeTxListener, type TxListener } from './utils' @@ -255,7 +255,7 @@ class Client { opcode: 'add', attachments: ops.add.map((it) => ({ ...it, - id: it.id ?? (generateUuid() as AttachmentID) + id: it.id ?? (uuid() as AttachmentID) })) }) } @@ -272,7 +272,7 @@ class Client { opcode: 'set', attachments: ops.set.map((it) => ({ ...it, - id: it.id ?? (generateUuid() as AttachmentID) + id: it.id ?? (uuid() as AttachmentID) })) }) } diff --git a/plugins/communication-resources/src/poll.ts b/plugins/communication-resources/src/poll.ts index c6a72c337d1..03c79b72e0a 100644 --- a/plugins/communication-resources/src/poll.ts +++ b/plugins/communication-resources/src/poll.ts @@ -22,7 +22,7 @@ import { type Timestamp } from '@hcengineering/core' import { type Poll, type PollAnswer } from '@hcengineering/communication' -import { getClient } from '@hcengineering/presentation' +import { getClient, getCommunicationClient } from '@hcengineering/presentation' import card, { type Card } from '@hcengineering/card' import { makeRank } from '@hcengineering/rank' import { type AppletAttachment, type MessageID } from '@hcengineering/communication-types' @@ -69,6 +69,7 @@ export function getEmptyPollConfig (): PollConfig { export async function createPoll (parent: Card, message: MessageID, params: PollConfig): Promise { const client = getClient() + const communicationClient = getCommunicationClient() const hierarchy = client.getHierarchy() const lastOne = await client.findOne(card.class.Card, {}, { sort: { rank: SortingOrder.Descending } }) @@ -85,6 +86,7 @@ export async function createPoll (parent: Card, message: MessageID, params: Poll const filledData = fillDefaults(hierarchy, data, communication.type.Poll) await client.createDoc(communication.type.Poll, parent.space, filledData, params.id) + await communicationClient.attachThread(parent._id, message, params.id, communication.type.Poll) } export function getPollTitle (attachment: AppletAttachment): string {