Skip to content

Commit

Permalink
Merge pull request #49 from DevKor-github/develop
Browse files Browse the repository at this point in the history
fix(aws): do not make exception when someone fails to delete obj from s3
  • Loading branch information
astorverse authored Jul 30, 2024
2 parents 7c14584 + 6ace5ac commit 29f1df5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/APIs/articles/services/articles-delete.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IArticlesServiceArticleUserIdPair } from '../interfaces/articles.servic
import { ArticlesReadRepository } from '../repositories/articles-read.repository';
import { ImagesService } from 'src/modules/images/images.service';
import { MergeExceptionMetadata } from '@/common/decorators/merge-exception-metadata.decorator';
import { IsUrl, isURL } from 'class-validator';

@Injectable()
export class ArticlesDeleteService {
Expand Down Expand Up @@ -45,11 +46,14 @@ export class ArticlesDeleteService {
const data = await this.repo_articlesRead.findOne({
where: { userId, id: articleId },
});
if (data) {
if (isURL(data.imageUrl)) {
await this.svc_images.deleteImage({ url: data.imageUrl });
}
if (isURL(data.mainImageUrl)) {
await this.svc_images.deleteImage({ url: data.mainImageUrl });
await this.svc_stickerBlocks.deleteStickerBlocks({ userId, articleId });
}
await this.svc_stickerBlocks.deleteStickerBlocks({ userId, articleId });

return await this.repo_articlesDelete.delete({
user: { id: userId },
id: articleId,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/aws/aws.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class AwsService {
return await this.s3Client.send(command);
} catch (error) {
this.logger.error('Error deleting object from S3', error.stack);
throw new BlccuException('IMAGE_DELETE_FROM_S3_ERROR');
// throw new BlccuException('IMAGE_DELETE_FROM_S3_ERROR');
}
}

Expand Down

0 comments on commit 29f1df5

Please sign in to comment.