Add files deletion when destroying attachment, workspace or workspaceMember (#10222)

Solution
- update attachment soft delete logic by destroy (seen with Weiko &
Felix)
- add two jobs for file and workspace folder deletion
- add listener to attachment and workspaceMember destroy event -> add
file deletion job
- update logic in deleteWorkspace method -> add wokspace folder deletion
job

closes https://github.com/twentyhq/core-team-issues/issues/147

To go further
- delete old avatar when workspaceMember replaces its avatar
- same with workspace picture

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
Etienne
2025-02-20 10:35:14 +01:00
committed by GitHub
parent 422e4e33c0
commit 316876fcb5
9 changed files with 212 additions and 6 deletions

View File

@ -5,7 +5,7 @@ import { PREVIEWABLE_EXTENSIONS } from '@/activities/files/components/DocumentVi
import { Attachment } from '@/activities/files/types/Attachment';
import { downloadFile } from '@/activities/files/utils/downloadFile';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord';
import { useDestroyOneRecord } from '@/object-record/hooks/useDestroyOneRecord';
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
import {
FieldContext,
@ -95,12 +95,12 @@ export const AttachmentRow = ({
[attachment?.id],
);
const { deleteOneRecord: deleteOneAttachment } = useDeleteOneRecord({
const { destroyOneRecord: destroyOneAttachment } = useDestroyOneRecord({
objectNameSingular: CoreObjectNameSingular.Attachment,
});
const handleDelete = () => {
deleteOneAttachment(attachment.id);
destroyOneAttachment(attachment.id);
};
const { updateOneRecord: updateOneAttachment } = useUpdateOneRecord({