Files - Migrate attachments in activities (#17808)
As attachment files have migrated from fullPath to file files field, need to migrate richText logic to fit to new attachment file handling + data migration
This commit is contained in:
+6
-1
@@ -4,11 +4,13 @@ import {
|
||||
type AttachmentInfo,
|
||||
getActivityAttachmentPathsAndName,
|
||||
} from '@/activities/utils/getActivityAttachmentPathsAndName';
|
||||
import { getAttachmentUrl } from '@/activities/utils/getAttachmentUrl';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const getActivityAttachmentIdsAndNameToUpdate = (
|
||||
newActivityBody: string,
|
||||
oldActivityAttachments: Attachment[] = [],
|
||||
isFilesFieldMigrated: boolean,
|
||||
) => {
|
||||
const activityAttachmentsNameAndPaths =
|
||||
getActivityAttachmentPathsAndName(newActivityBody);
|
||||
@@ -17,7 +19,10 @@ export const getActivityAttachmentIdsAndNameToUpdate = (
|
||||
return activityAttachmentsNameAndPaths.reduce(
|
||||
(acc: Partial<Attachment>[], activity: AttachmentInfo) => {
|
||||
const foundActivity = oldActivityAttachments.find((attachment) =>
|
||||
compareUrls(attachment.fullPath, activity.path),
|
||||
compareUrls(
|
||||
getAttachmentUrl({ attachment, isFilesFieldMigrated }),
|
||||
activity.path,
|
||||
),
|
||||
);
|
||||
if (isDefined(foundActivity) && foundActivity.name !== activity.name) {
|
||||
acc.push({ id: foundActivity.id, name: activity.name });
|
||||
|
||||
Reference in New Issue
Block a user