Enable new record board and messaging for all workspaces except demo (#4243)
* Enable new record board and messaging for all workspaces except demo * Fix according to PR
This commit is contained in:
@ -5,10 +5,6 @@ import { Repository } from 'typeorm';
|
||||
|
||||
import { MessageQueueJob } from 'src/integrations/message-queue/interfaces/message-queue-job.interface';
|
||||
|
||||
import {
|
||||
FeatureFlagEntity,
|
||||
FeatureFlagKeys,
|
||||
} from 'src/core/feature-flag/feature-flag.entity';
|
||||
import { MessageQueue } from 'src/integrations/message-queue/message-queue.constants';
|
||||
import { MessageQueueService } from 'src/integrations/message-queue/services/message-queue.service';
|
||||
import { ConnectedAccountService } from 'src/workspace/messaging/repositories/connected-account/connected-account.service';
|
||||
@ -16,29 +12,29 @@ import {
|
||||
GmailPartialSyncJobData,
|
||||
GmailPartialSyncJob,
|
||||
} from 'src/workspace/messaging/jobs/gmail-partial-sync.job';
|
||||
import { Workspace } from 'src/core/workspace/workspace.entity';
|
||||
|
||||
@Injectable()
|
||||
export class FetchAllWorkspacesMessagesJob
|
||||
implements MessageQueueJob<undefined>
|
||||
{
|
||||
constructor(
|
||||
@InjectRepository(FeatureFlagEntity, 'core')
|
||||
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
|
||||
@InjectRepository(Workspace, 'core')
|
||||
private readonly workspaceRepository: Repository<Workspace>,
|
||||
@Inject(MessageQueue.messagingQueue)
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
private readonly connectedAccountService: ConnectedAccountService,
|
||||
) {}
|
||||
|
||||
async handle(): Promise<void> {
|
||||
const featureFlagsWithMessagingEnabled =
|
||||
await this.featureFlagRepository.findBy({
|
||||
key: FeatureFlagKeys.IsMessagingEnabled,
|
||||
value: true,
|
||||
});
|
||||
|
||||
const workspaceIds = featureFlagsWithMessagingEnabled.map(
|
||||
(featureFlag) => featureFlag.workspaceId,
|
||||
);
|
||||
const workspaceIds = (
|
||||
await this.workspaceRepository.find({
|
||||
where: {
|
||||
subscriptionStatus: 'active',
|
||||
},
|
||||
select: ['id'],
|
||||
})
|
||||
).map((workspace) => workspace.id);
|
||||
|
||||
for (const workspaceId of workspaceIds) {
|
||||
await this.fetchWorkspaceMessages(workspaceId);
|
||||
|
||||
@ -1,13 +1,7 @@
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Inject } from '@nestjs/common';
|
||||
|
||||
import { Command, CommandRunner, Option } from 'nest-commander';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
FeatureFlagEntity,
|
||||
FeatureFlagKeys,
|
||||
} from 'src/core/feature-flag/feature-flag.entity';
|
||||
import { MessageQueue } from 'src/integrations/message-queue/message-queue.constants';
|
||||
import { MessageQueueService } from 'src/integrations/message-queue/services/message-queue.service';
|
||||
import {
|
||||
@ -26,8 +20,6 @@ interface GmailFullSyncOptions {
|
||||
})
|
||||
export class GmailFullSyncCommand extends CommandRunner {
|
||||
constructor(
|
||||
@InjectRepository(FeatureFlagEntity, 'core')
|
||||
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
|
||||
@Inject(MessageQueue.messagingQueue)
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
private readonly connectedAccountService: ConnectedAccountService,
|
||||
@ -39,16 +31,6 @@ export class GmailFullSyncCommand extends CommandRunner {
|
||||
_passedParam: string[],
|
||||
options: GmailFullSyncOptions,
|
||||
): Promise<void> {
|
||||
const isMessagingEnabled = await this.featureFlagRepository.findOneBy({
|
||||
workspaceId: options.workspaceId,
|
||||
key: FeatureFlagKeys.IsMessagingEnabled,
|
||||
value: true,
|
||||
});
|
||||
|
||||
if (!isMessagingEnabled) {
|
||||
throw new Error('Messaging is not enabled for this workspace');
|
||||
}
|
||||
|
||||
await this.fetchWorkspaceMessages(options.workspaceId);
|
||||
|
||||
return;
|
||||
|
||||
@ -1,13 +1,7 @@
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Inject } from '@nestjs/common';
|
||||
|
||||
import { Command, CommandRunner, Option } from 'nest-commander';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
FeatureFlagEntity,
|
||||
FeatureFlagKeys,
|
||||
} from 'src/core/feature-flag/feature-flag.entity';
|
||||
import { MessageQueue } from 'src/integrations/message-queue/message-queue.constants';
|
||||
import { MessageQueueService } from 'src/integrations/message-queue/services/message-queue.service';
|
||||
import {
|
||||
@ -26,8 +20,6 @@ interface GmailPartialSyncOptions {
|
||||
})
|
||||
export class GmailPartialSyncCommand extends CommandRunner {
|
||||
constructor(
|
||||
@InjectRepository(FeatureFlagEntity, 'core')
|
||||
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
|
||||
@Inject(MessageQueue.messagingQueue)
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
private readonly connectedAccountService: ConnectedAccountService,
|
||||
@ -39,16 +31,6 @@ export class GmailPartialSyncCommand extends CommandRunner {
|
||||
_passedParam: string[],
|
||||
options: GmailPartialSyncOptions,
|
||||
): Promise<void> {
|
||||
const isMessagingEnabled = await this.featureFlagRepository.findOneBy({
|
||||
workspaceId: options.workspaceId,
|
||||
key: FeatureFlagKeys.IsMessagingEnabled,
|
||||
value: true,
|
||||
});
|
||||
|
||||
if (!isMessagingEnabled) {
|
||||
throw new Error('Messaging is not enabled for this workspace');
|
||||
}
|
||||
|
||||
await this.fetchWorkspaceMessages(options.workspaceId);
|
||||
|
||||
return;
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
FeatureFlagEntity,
|
||||
FeatureFlagKeys,
|
||||
} from 'src/core/feature-flag/feature-flag.entity';
|
||||
import { ObjectRecordCreateEvent } from 'src/integrations/event-emitter/types/object-record-create.event';
|
||||
import { ObjectRecordUpdateEvent } from 'src/integrations/event-emitter/types/object-record-update.event';
|
||||
import { objectRecordChangedProperties as objectRecordUpdateEventChangedProperties } from 'src/integrations/event-emitter/utils/object-record-changed-properties.util';
|
||||
@ -24,8 +17,6 @@ export class MessagingPersonListener {
|
||||
constructor(
|
||||
@Inject(MessageQueue.messagingQueue)
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
@InjectRepository(FeatureFlagEntity, 'core')
|
||||
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
|
||||
) {}
|
||||
|
||||
@OnEvent('person.created')
|
||||
@ -36,16 +27,6 @@ export class MessagingPersonListener {
|
||||
return;
|
||||
}
|
||||
|
||||
const messagingFeatureFlag = await this.featureFlagRepository.findOneBy({
|
||||
key: FeatureFlagKeys.IsMessagingEnabled,
|
||||
value: true,
|
||||
workspaceId: payload.workspaceId,
|
||||
});
|
||||
|
||||
if (!messagingFeatureFlag || !messagingFeatureFlag.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.messageQueueService.add<MatchMessageParticipantsJobData>(
|
||||
MatchMessageParticipantJob.name,
|
||||
{
|
||||
@ -60,21 +41,11 @@ export class MessagingPersonListener {
|
||||
async handleUpdatedEvent(
|
||||
payload: ObjectRecordUpdateEvent<PersonObjectMetadata>,
|
||||
) {
|
||||
const messagingFeatureFlag = await this.featureFlagRepository.findOneBy({
|
||||
key: FeatureFlagKeys.IsMessagingEnabled,
|
||||
value: true,
|
||||
workspaceId: payload.workspaceId,
|
||||
});
|
||||
|
||||
const isMessagingEnabled =
|
||||
messagingFeatureFlag && messagingFeatureFlag.value;
|
||||
|
||||
if (
|
||||
objectRecordUpdateEventChangedProperties(
|
||||
payload.previousRecord,
|
||||
payload.updatedRecord,
|
||||
).includes('email') &&
|
||||
isMessagingEnabled
|
||||
).includes('email')
|
||||
) {
|
||||
this.messageQueueService.add<MatchMessageParticipantsJobData>(
|
||||
MatchMessageParticipantJob.name,
|
||||
|
||||
@ -4,10 +4,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
FeatureFlagEntity,
|
||||
FeatureFlagKeys,
|
||||
} from 'src/core/feature-flag/feature-flag.entity';
|
||||
import { FeatureFlagEntity } from 'src/core/feature-flag/feature-flag.entity';
|
||||
import { ObjectRecordCreateEvent } from 'src/integrations/event-emitter/types/object-record-create.event';
|
||||
import { ObjectRecordUpdateEvent } from 'src/integrations/event-emitter/types/object-record-update.event';
|
||||
import { objectRecordChangedProperties as objectRecordUpdateEventChangedProperties } from 'src/integrations/event-emitter/utils/object-record-changed-properties.util';
|
||||
@ -36,16 +33,6 @@ export class MessagingWorkspaceMemberListener {
|
||||
return;
|
||||
}
|
||||
|
||||
const messagingFeatureFlag = await this.featureFlagRepository.findOneBy({
|
||||
key: FeatureFlagKeys.IsMessagingEnabled,
|
||||
value: true,
|
||||
workspaceId: payload.workspaceId,
|
||||
});
|
||||
|
||||
if (!messagingFeatureFlag || !messagingFeatureFlag.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.messageQueueService.add<MatchMessageParticipantsJobData>(
|
||||
MatchMessageParticipantJob.name,
|
||||
{
|
||||
@ -60,21 +47,11 @@ export class MessagingWorkspaceMemberListener {
|
||||
async handleUpdatedEvent(
|
||||
payload: ObjectRecordUpdateEvent<WorkspaceMemberObjectMetadata>,
|
||||
) {
|
||||
const messagingFeatureFlag = await this.featureFlagRepository.findOneBy({
|
||||
key: FeatureFlagKeys.IsMessagingEnabled,
|
||||
value: true,
|
||||
workspaceId: payload.workspaceId,
|
||||
});
|
||||
|
||||
const isMessagingEnabled =
|
||||
messagingFeatureFlag && messagingFeatureFlag.value;
|
||||
|
||||
if (
|
||||
objectRecordUpdateEventChangedProperties(
|
||||
payload.previousRecord,
|
||||
payload.updatedRecord,
|
||||
).includes('userEmail') &&
|
||||
isMessagingEnabled
|
||||
).includes('userEmail')
|
||||
) {
|
||||
this.messageQueueService.add<MatchMessageParticipantsJobData>(
|
||||
MatchMessageParticipantJob.name,
|
||||
|
||||
Reference in New Issue
Block a user