connected accounts follow up (#18998)
- Fixed group emails actions - Fixed delta updates for folder manager - Updated crons
This commit is contained in:
+2
@@ -5,12 +5,14 @@ import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-
|
||||
import { ConnectedAccountDataAccessModule } from 'src/engine/metadata-modules/connected-account/data-access/connected-account-data-access.module';
|
||||
import { MessageChannelDataAccessService } from 'src/engine/metadata-modules/message-channel/data-access/services/message-channel-data-access.service';
|
||||
import { MessageChannelEntity } from 'src/engine/metadata-modules/message-channel/entities/message-channel.entity';
|
||||
import { MessageFolderDataAccessModule } from 'src/engine/metadata-modules/message-folder/data-access/message-folder-data-access.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([MessageChannelEntity]),
|
||||
FeatureFlagModule,
|
||||
ConnectedAccountDataAccessModule,
|
||||
MessageFolderDataAccessModule,
|
||||
],
|
||||
providers: [MessageChannelDataAccessService],
|
||||
exports: [MessageChannelDataAccessService],
|
||||
|
||||
+10
-8
@@ -12,6 +12,7 @@ import {
|
||||
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
|
||||
import { ConnectedAccountDataAccessService } from 'src/engine/metadata-modules/connected-account/data-access/services/connected-account-data-access.service';
|
||||
import { MessageChannelEntity } from 'src/engine/metadata-modules/message-channel/entities/message-channel.entity';
|
||||
import { MessageFolderDataAccessService } from 'src/engine/metadata-modules/message-folder/data-access/services/message-folder-data-access.service';
|
||||
import { type WorkspaceEntityManager } from 'src/engine/twenty-orm/entity-manager/workspace-entity-manager';
|
||||
import { GlobalWorkspaceOrmManager } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager';
|
||||
import { type MessageChannelWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-channel.workspace-entity';
|
||||
@@ -26,6 +27,7 @@ export class MessageChannelDataAccessService {
|
||||
private readonly featureFlagService: FeatureFlagService,
|
||||
private readonly globalWorkspaceOrmManager: GlobalWorkspaceOrmManager,
|
||||
private readonly connectedAccountDataAccessService: ConnectedAccountDataAccessService,
|
||||
private readonly messageFolderDataAccessService: MessageFolderDataAccessService,
|
||||
) {}
|
||||
|
||||
private async isMigrated(workspaceId: string): Promise<boolean> {
|
||||
@@ -133,15 +135,15 @@ export class MessageChannelDataAccessService {
|
||||
}
|
||||
|
||||
if (needsMessageFolders) {
|
||||
const workspaceRepository =
|
||||
await this.getWorkspaceRepository(workspaceId);
|
||||
const messageFolders = await this.messageFolderDataAccessService.find(
|
||||
workspaceId,
|
||||
{
|
||||
messageChannelId: result.id,
|
||||
},
|
||||
);
|
||||
|
||||
const workspaceChannel = await workspaceRepository.findOne({
|
||||
where: { id: result.id },
|
||||
relations: ['messageFolders'],
|
||||
});
|
||||
|
||||
workspaceResult.messageFolders = workspaceChannel?.messageFolders ?? [];
|
||||
workspaceResult.messageFolders =
|
||||
messageFolders as unknown as MessageChannelWorkspaceEntity['messageFolders'];
|
||||
}
|
||||
|
||||
return workspaceResult;
|
||||
|
||||
+11
-3
@@ -38,15 +38,17 @@ export class MessageFolderDataAccessService {
|
||||
private async toCore(
|
||||
workspaceId: string,
|
||||
data: Partial<MessageFolderWorkspaceEntity>,
|
||||
messageChannelId?: string,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const coreData: Record<string, unknown> = { ...data, workspaceId };
|
||||
const parentFolderId = coreData.parentFolderId as string | null;
|
||||
const channelId = (coreData.messageChannelId as string) ?? messageChannelId;
|
||||
|
||||
if (parentFolderId && !uuidValidate(parentFolderId)) {
|
||||
if (parentFolderId && !uuidValidate(parentFolderId) && channelId) {
|
||||
const parentFolder = await this.coreRepository.findOne({
|
||||
where: {
|
||||
workspaceId,
|
||||
messageChannelId: coreData.messageChannelId as string,
|
||||
messageChannelId: channelId,
|
||||
externalId: parentFolderId,
|
||||
},
|
||||
select: ['id'],
|
||||
@@ -146,9 +148,15 @@ export class MessageFolderDataAccessService {
|
||||
|
||||
if (await this.isMigrated(workspaceId)) {
|
||||
try {
|
||||
const coreData = await this.toCore(
|
||||
workspaceId,
|
||||
data,
|
||||
(where as Record<string, unknown>).messageChannelId as string,
|
||||
);
|
||||
|
||||
await this.coreRepository.update(
|
||||
{ ...where, workspaceId } as FindOptionsWhere<MessageFolderEntity>,
|
||||
data as Record<string, unknown>,
|
||||
coreData,
|
||||
);
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
|
||||
Reference in New Issue
Block a user