fix: admin couldn't delete shares created by anonymous users

This commit is contained in:
Elias Schneider
2024-05-17 15:13:56 +02:00
parent a3a7a5d9ab
commit 7afda85f03
3 changed files with 19 additions and 7 deletions

View File

@@ -267,13 +267,14 @@ export class ShareService {
return share;
}
async remove(shareId: string) {
async remove(shareId: string, isDeleterAdmin = false) {
const share = await this.prisma.share.findUnique({
where: { id: shareId },
});
if (!share) throw new NotFoundException("Share not found");
if (!share.creatorId)
if (!share.creatorId && !isDeleterAdmin)
throw new ForbiddenException("Anonymous shares can't be deleted");
await this.fileService.deleteAllFiles(shareId);