The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Remove dead Unsubscribe rewrite from the 2-46 assignee command (#27563)
Félix Malfaitb3db2a31f62c
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-46/2-46-workspace-command-1791385745099-add-agent-chat-thread-assignee.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-46/2-46-workspace-command-1791385745099-add-agent-chat-thread-assignee.command.tsindex e41045dceb3..e8707dfa7cf 100644--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-46/2-46-workspace-command-1791385745099-add-agent-chat-thread-assignee.command.ts+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-46/2-46-workspace-command-1791385745099-add-agent-chat-thread-assignee.command.ts@@ -13,7 +13,6 @@ import { backfillAgentChatThreadInboxState } from 'src/database/commands/upgradeimport { ApplicationService } from 'src/engine/core-modules/application/application.service';import { RegisteredWorkspaceCommand } from 'src/engine/core-modules/upgrade/decorators/registered-workspace-command.decorator';import { findFlatEntityByUniversalIdentifier } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-universal-identifier.util';-import { type FlatCommandMenuItem } from 'src/engine/metadata-modules/flat-command-menu-item/types/flat-command-menu-item.type';import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';import { type FlatIndexMetadata } from 'src/engine/metadata-modules/flat-index-metadata/types/flat-index-metadata.type';import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';@@ -34,56 +33,6 @@ const ASSIGNEE_INDEX_UNIVERSAL_IDENTIFIERS = [const ASSIGNEE_COMMAND_MENU_ITEM_NAMES = ['assignAiChat'] as const;-// The assignee cannot unsubscribe, so Unsubscribe hides for them. Only an-// expression still as the subscriptions command saved it is changed-const UNSUBSCRIBE_EXPRESSION_BEFORE_ASSIGNEES =- 'numberOfSelectedRecords >= 1 and permissionFlags.AI and noneDefined(selectedRecords, "deletedAt") and everyEquals(selectedRecords, "inboxStatus.isSubscribed", true)';--const UNSUBSCRIBE_EXPRESSION_WITH_ASSIGNEES = `${UNSUBSCRIBE_EXPRESSION_BEFORE_ASSIGNEES} and noneEquals(selectedRecords, "inboxStatus.isAssignedToMe", true)`;--const buildUnsubscribeCommandMenuItemUpdates = ({- flatCommandMenuItemByUniversalIdentifier,- now,- direction,-}: {- flatCommandMenuItemByUniversalIdentifier: Record<- string,- FlatCommandMenuItem | undefined- >;- now: string;- direction: 'up' | 'down';-}): FlatCommandMenuItem[] => {- const commandMenuItem =- flatCommandMenuItemByUniversalIdentifier[- STANDARD_COMMAND_MENU_ITEMS.unsubscribeFromAiChat.universalIdentifier- ];- const [fromExpression, toExpression] =- direction === 'up'- ? [- UNSUBSCRIBE_EXPRESSION_BEFORE_ASSIGNEES,- UNSUBSCRIBE_EXPRESSION_WITH_ASSIGNEES,- ]- : [- UNSUBSCRIBE_EXPRESSION_WITH_ASSIGNEES,- UNSUBSCRIBE_EXPRESSION_BEFORE_ASSIGNEES,- ];-- if (- !isDefined(commandMenuItem) ||- commandMenuItem.conditionalAvailabilityExpression !== fromExpression- ) {- return [];- }-- return [- {- ...commandMenuItem,- conditionalAvailabilityExpression: toExpression,- updatedAt: now,- },- ];-};-@RegisteredWorkspaceCommand('2.46.0', 1791385745099)@Command({name: 'upgrade:2-46:add-agent-chat-thread-assignee',@@ -166,25 +115,18 @@ export class AddAgentChatThreadAssigneeCommand extends ProvisionedWorkspaceCommanow: new Date().toISOString(),});- const commandMenuItemsToUpdate = buildUnsubscribeCommandMenuItemUpdates({- flatCommandMenuItemByUniversalIdentifier:- flatCommandMenuItemMaps.byUniversalIdentifier,- now: new Date().toISOString(),- direction: 'up',- });const operationCount =fieldsToCreate.length +indexesToCreate.length +- commandMenuItemsToCreate.length +- commandMenuItemsToUpdate.length;+ commandMenuItemsToCreate.length;if (operationCount === 0) {return;}this.logger.log(- `${options.dryRun ? '[DRY RUN] ' : ''}Workspace ${workspaceId}: creating ${fieldsToCreate.length} field(s), ${indexesToCreate.length} index(es) and ${commandMenuItemsToCreate.length} command menu item(s), and updating ${commandMenuItemsToUpdate.length} command menu item(s) for chat assignees`,+ `${options.dryRun ? '[DRY RUN] ' : ''}Workspace ${workspaceId}: creating ${fieldsToCreate.length} field(s), ${indexesToCreate.length} index(es) and ${commandMenuItemsToCreate.length} command menu item(s) for chat assignees`,);if (options.dryRun ?? false) {@@ -237,7 +179,7 @@ export class AddAgentChatThreadAssigneeCommand extends ProvisionedWorkspaceCommacommandMenuItem: {flatEntityToCreate: commandMenuItemsToCreate,flatEntityToDelete: [],- flatEntityToUpdate: commandMenuItemsToUpdate,+ flatEntityToUpdate: [],},},},@@ -279,18 +221,11 @@ export class AddAgentChatThreadAssigneeCommand extends ProvisionedWorkspaceCommaSTANDARD_COMMAND_MENU_ITEMS[name].universalIdentifier],).filter(isDefined);- const commandMenuItemsToUpdate = buildUnsubscribeCommandMenuItemUpdates({- flatCommandMenuItemByUniversalIdentifier:- flatCommandMenuItemMaps.byUniversalIdentifier,- now: new Date().toISOString(),- direction: 'down',- });if (fieldsToDelete.length +indexesToDelete.length +- commandMenuItemsToDelete.length +- commandMenuItemsToUpdate.length ===+ commandMenuItemsToDelete.length ===0) {return;@@ -325,7 +260,7 @@ export class AddAgentChatThreadAssigneeCommand extends ProvisionedWorkspaceCommacommandMenuItem: {flatEntityToCreate: [],flatEntityToDelete: commandMenuItemsToDelete,- flatEntityToUpdate: commandMenuItemsToUpdate,+ flatEntityToUpdate: [],},},},diff --git a/packages/twenty-server/test/integration/upgrade/suites/2-46-workspace-command-1791385745099-add-agent-chat-thread-assignee.integration-spec.ts b/packages/twenty-server/test/integration/upgrade/suites/2-46-workspace-command-1791385745099-add-agent-chat-thread-assignee.integration-spec.tsindex 7520d884765..219c131d91b 100644--- a/packages/twenty-server/test/integration/upgrade/suites/2-46-workspace-command-1791385745099-add-agent-chat-thread-assignee.integration-spec.ts+++ b/packages/twenty-server/test/integration/upgrade/suites/2-46-workspace-command-1791385745099-add-agent-chat-thread-assignee.integration-spec.ts@@ -54,12 +54,6 @@ describe('2-46 workspace command - add agent chat thread assignee (integration)'flatCommandMenuItemMaps.byUniversalIdentifier[STANDARD_COMMAND_MENU_ITEMS.assignAiChat.universalIdentifier] !== undefined,- isUnsubscribeHiddenFromAssignee:- flatCommandMenuItemMaps.byUniversalIdentifier[- STANDARD_COMMAND_MENU_ITEMS.unsubscribeFromAiChat.universalIdentifier- ]?.conditionalAvailabilityExpression?.includes(- 'inboxStatus.isAssignedToMe',- ) ?? false,};};@@ -74,7 +68,7 @@ describe('2-46 workspace command - add agent chat thread assignee (integration)'};// An earlier suite may have rebuilt the chat objects without the- // Unsubscribe command, which the upgrade adds before this one+ // subscriptions, which the upgrade adds before this onebeforeAll(async () => {command = getAppProviderByClassName<AddAgentChatThreadAssigneeCommand>('AddAgentChatThreadAssigneeCommand',@@ -95,7 +89,6 @@ describe('2-46 workspace command - add agent chat thread assignee (integration)'fieldCount: 0,hasIndex: false,hasCommandMenuItem: false,- isUnsubscribeHiddenFromAssignee: false,});expect(await hasAssigneeColumn()).toBe(false);});@@ -107,7 +100,6 @@ describe('2-46 workspace command - add agent chat thread assignee (integration)'fieldCount: 2,hasIndex: true,hasCommandMenuItem: true,- isUnsubscribeHiddenFromAssignee: true,});expect(await hasAssigneeColumn()).toBe(true);});@@ -118,7 +110,6 @@ describe('2-46 workspace command - add agent chat thread assignee (integration)'fieldCount: 2,hasIndex: true,hasCommandMenuItem: true,- isUnsubscribeHiddenFromAssignee: true,});});});