From 95466cadd1c5369a904c6f9b5b53f63dcd035f07 Mon Sep 17 00:00:00 2001 From: Romaric Mourgues Date: Fri, 20 May 2022 14:18:03 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=20Fix=20canary=20breaking=20change?= =?UTF-8?q?s=20(#2179)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix canary before release * 🛠 Fix deps (#2126) --- twake/backend/node/package.json | 6 +++++- .../src/core/platform/services/webserver/index.ts | 4 ++-- .../src/services/channels/services/pubsub/index.ts | 2 +- twake/backend/node/src/services/global-resolver.ts | 3 +++ .../services/messages/entities/message-file-refs.ts | 9 ++++++--- .../services/engine/processors/files/index.ts | 11 +++++++---- .../node/src/services/messages/services/views.ts | 6 +++++- 7 files changed, 29 insertions(+), 12 deletions(-) diff --git a/twake/backend/node/package.json b/twake/backend/node/package.json index 82b2927602..c0860ea82b 100644 --- a/twake/backend/node/package.json +++ b/twake/backend/node/package.json @@ -59,6 +59,7 @@ "@types/config": "0.0.36", "@types/eslint": "^7.2.3", "@types/fastify-multipart": "^0.7.0", + "@types/fastify-static": "^2.2.1", "@types/jest": "^26.0.14", "@types/lodash": "^4.14.165", "@types/minio": "^7.0.7", @@ -97,6 +98,8 @@ }, "dependencies": { "@elastic/elasticsearch": "7", + "@fastify/formbody": "^6.0.0", + "@fastify/static": "^5.0.1", "@sentry/node": "^6.15.0", "@sentry/tracing": "^6.15.0", "@socket.io/redis-adapter": "^7.1.0", @@ -120,8 +123,9 @@ "fastify-jwt": "^2.2.0", "fastify-multipart": "5.3.1", "fastify-plugin": "^2.3.4", - "fastify-sensible": "^3.0.1", + "fastify-sensible": "=3.0.1", "fastify-socket.io": "^3.0.0", + "fastify-static": "^4.7.0", "fastify-swagger": "^4.12.6", "fastify-websocket": "^2.0.11", "find-my-way": "^5.2.0", diff --git a/twake/backend/node/src/core/platform/services/webserver/index.ts b/twake/backend/node/src/core/platform/services/webserver/index.ts index 761a8a065e..53c4c4772a 100644 --- a/twake/backend/node/src/core/platform/services/webserver/index.ts +++ b/twake/backend/node/src/core/platform/services/webserver/index.ts @@ -3,8 +3,8 @@ import { Server, IncomingMessage, ServerResponse } from "http"; import { FastifyInstance, fastify } from "fastify"; import sensible from "fastify-sensible"; import multipart from "fastify-multipart"; -import formbody from "fastify-formbody"; -import fastifyStatic from "fastify-static"; +import formbody from "@fastify/formbody"; +import fastifyStatic from "@fastify/static"; import corsPlugin, { FastifyCorsOptions } from "fastify-cors"; import { serverErrorHandler } from "./error"; import WebServerAPI from "./provider"; diff --git a/twake/backend/node/src/services/channels/services/pubsub/index.ts b/twake/backend/node/src/services/channels/services/pubsub/index.ts index 28679389a5..32f7c7d72d 100644 --- a/twake/backend/node/src/services/channels/services/pubsub/index.ts +++ b/twake/backend/node/src/services/channels/services/pubsub/index.ts @@ -6,7 +6,7 @@ import { NewPendingEmailsInWorkspaceJoinChannelsProcessor } from "./new-pending- import { NewWorkspaceProcessor } from "./new-workspace"; import gr from "../../../global-resolver"; -export class PubsubListener implements Initializable { +export class ChannelsPubsubListener implements Initializable { async init(): Promise { const channelActivityProcessor = await new NewChannelActivityProcessor().init(); gr.platformServices.pubsub.processor.addHandler(channelActivityProcessor); diff --git a/twake/backend/node/src/services/global-resolver.ts b/twake/backend/node/src/services/global-resolver.ts index 9138ce302a..7b0e7b8c4e 100644 --- a/twake/backend/node/src/services/global-resolver.ts +++ b/twake/backend/node/src/services/global-resolver.ts @@ -73,6 +73,7 @@ import { ApplicationHooksService } from "./applications/services/hooks"; import { OnlineServiceAPI } from "./online/api"; import OnlineServiceImpl from "./online/service"; import { PreviewEngine } from "./previews/services/engine"; +import { ChannelsPubsubListener } from "./channels/services/pubsub"; type PlatformServices = { auth: AuthServiceAPI; @@ -120,6 +121,7 @@ type TwakeServices = { channels: { channels: ChannelService; members: MemberService; + pubsub: ChannelsPubsubListener; }; channelPendingEmail: ChannelPendingEmailService; tab: TabService; @@ -196,6 +198,7 @@ class GlobalResolver { channels: { channels: await new ChannelServiceImpl().init(), members: await new MemberServiceImpl().init(), + pubsub: await new ChannelsPubsubListener().init(), }, channelPendingEmail: await new ChannelPendingEmailServiceImpl().init(), tab: await new TabServiceImpl().init(), diff --git a/twake/backend/node/src/services/messages/entities/message-file-refs.ts b/twake/backend/node/src/services/messages/entities/message-file-refs.ts index 836ba98a84..d4eaa1367e 100644 --- a/twake/backend/node/src/services/messages/entities/message-file-refs.ts +++ b/twake/backend/node/src/services/messages/entities/message-file-refs.ts @@ -4,7 +4,7 @@ import { Column, Entity } from "../../../core/platform/services/database/service export const TYPE = "message_file_refs"; @Entity(TYPE, { - primaryKey: [["target_type", "target_id"], "id"], + primaryKey: [["target_type", "company_id", "target_id"], "id"], type: TYPE, }) export class MessageFileRef { @@ -41,8 +41,11 @@ export class MessageFileRef { message_id: string; @Type(() => String) - @Column("file_id", "string") - file_id: string; + @Column("message_file_id", "string") + message_file_id: string; + + @Column("company_id", "timeuuid") + company_id: string; } export type MessageFileRefPrimaryKey = Pick; diff --git a/twake/backend/node/src/services/messages/services/engine/processors/files/index.ts b/twake/backend/node/src/services/messages/services/engine/processors/files/index.ts index b5a69bfa58..bd2c31d163 100644 --- a/twake/backend/node/src/services/messages/services/engine/processors/files/index.ts +++ b/twake/backend/node/src/services/messages/services/engine/processors/files/index.ts @@ -3,6 +3,7 @@ import { Thread } from "../../../../entities/threads"; import Repository from "../../../../../../core/platform/services/database/services/orm/repository/repository"; import { getInstance, MessageFileRef } from "../../../../entities/message-file-refs"; import gr from "../../../../../global-resolver"; +import uuid from "node-uuid"; export class FilesViewProcessor { repository: Repository; @@ -22,13 +23,14 @@ export class FilesViewProcessor { const fileRef = getInstance({ target_type: "channel", target_id: participant.id, - id: file.id, + id: uuid.v1(), created_at: message.resource.created_at, workspace_id: participant.workspace_id, channel_id: participant.id, thread_id: thread.id, message_id: message.resource.id, - file_id: file.id, + message_file_id: file.id, + company_id: file.company_id, }); this.repository.save(fileRef); } @@ -37,13 +39,14 @@ export class FilesViewProcessor { const fileRef = getInstance({ target_type: "user_upload", target_id: message.resource.user_id, - id: file.id, + id: uuid.v1(), created_at: message.resource.created_at, workspace_id: "", channel_id: "", thread_id: thread.id, message_id: message.resource.id, - file_id: file.id, + message_file_id: file.id, + company_id: file.company_id, }); this.repository.save(fileRef); } diff --git a/twake/backend/node/src/services/messages/services/views.ts b/twake/backend/node/src/services/messages/services/views.ts index 4d69c4496e..2515bb9d4d 100644 --- a/twake/backend/node/src/services/messages/services/views.ts +++ b/twake/backend/node/src/services/messages/services/views.ts @@ -60,7 +60,11 @@ export class ViewsServiceImpl implements MessageViewsServiceAPI { context?: ChannelViewExecutionContext, ): Promise> { const refs = await this.repositoryFilesRef.find( - { target_type: "channel", target_id: context.channel.id }, + { + target_type: "channel", + target_id: context.channel.id, + company_id: context.channel.company_id, + }, buildMessageListPagination(pagination, "id"), );