🐛 Fixed problem with deleting files uploaded by an application (#793)

This commit is contained in:
Anton Shepilov
2025-01-27 16:40:47 +01:00
committed by GitHub
parent 5bace9c97e
commit 20d128d990
4 changed files with 30 additions and 3 deletions
@@ -419,9 +419,9 @@ export const getItemScope = async (
context: CompanyExecutionContext,
): Promise<"personal" | "shared"> => {
let scope: "personal" | "shared";
if (item.parent_id.startsWith("user_")) {
if (item.parent_id.startsWith("user_") || item.parent_id.startsWith("trash_")) {
scope = "personal";
} else if (item.parent_id === "root") {
} else if (item.parent_id === "root" || item.parent_id === "trash") {
scope = "shared";
} else {
const driveItemParent = await repository.findOne(
@@ -821,7 +821,8 @@ export class DocumentsService {
// Check item belongs to someone
if (item.creator !== context?.user?.id) {
const creator = await this.userRepository.findOne({ id: item.creator });
if (creator.type === "anonymous") {
//if the file was created by an application or anonymous user
if (creator == null || creator.type === "anonymous") {
const loadedCreators = new Map<string, User>();
let firstOwnedItem: DriveFile | undefined;
for (let i = path.length - 1; i >= 0; i--) {