@aurispec/core-backend 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/database/migrations/1772984882048-modified_reviews_table.d.ts +7 -0
  2. package/dist/database/migrations/1772984882048-modified_reviews_table.d.ts.map +1 -0
  3. package/dist/database/migrations/1772984882048-modified_reviews_table.js +61 -0
  4. package/dist/database/migrations/1773052871526-modified_categories_table.d.ts +7 -0
  5. package/dist/database/migrations/1773052871526-modified_categories_table.d.ts.map +1 -0
  6. package/dist/database/migrations/1773052871526-modified_categories_table.js +19 -0
  7. package/dist/models/BusinessModel.d.ts +2 -0
  8. package/dist/models/BusinessModel.d.ts.map +1 -1
  9. package/dist/models/BusinessModel.js +9 -0
  10. package/dist/models/CategoryModel.d.ts +2 -0
  11. package/dist/models/CategoryModel.d.ts.map +1 -1
  12. package/dist/models/CategoryModel.js +10 -0
  13. package/dist/models/ReviewModel.d.ts +5 -0
  14. package/dist/models/ReviewModel.d.ts.map +1 -1
  15. package/dist/models/ReviewModel.js +20 -1
  16. package/dist/models/UserModel.d.ts +2 -0
  17. package/dist/models/UserModel.d.ts.map +1 -1
  18. package/dist/models/UserModel.js +9 -0
  19. package/package.json +1 -1
  20. package/dist/app.js +0 -59
  21. package/dist/common/configs/express.js +0 -29
  22. package/dist/common/configs/websocket.js +0 -17
  23. package/dist/common/constants/chat.d.ts +0 -18
  24. package/dist/common/constants/chat.d.ts.map +0 -1
  25. package/dist/common/constants/chat.js +0 -20
  26. package/dist/common/constants/messages/admin.messages.d.ts +0 -33
  27. package/dist/common/constants/messages/admin.messages.d.ts.map +0 -1
  28. package/dist/common/constants/messages/admin.messages.js +0 -35
  29. package/dist/common/constants/messages/user.messages.d.ts +0 -33
  30. package/dist/common/constants/messages/user.messages.d.ts.map +0 -1
  31. package/dist/common/constants/messages/user.messages.js +0 -35
  32. package/dist/common/dtos/AdminDto.d.ts +0 -5
  33. package/dist/common/dtos/AdminDto.d.ts.map +0 -1
  34. package/dist/common/dtos/AdminDto.js +0 -30
  35. package/dist/common/dtos/ArticleDto.d.ts +0 -11
  36. package/dist/common/dtos/ArticleDto.d.ts.map +0 -1
  37. package/dist/common/dtos/ArticleDto.js +0 -61
  38. package/dist/common/dtos/BusinessDto.d.ts +0 -12
  39. package/dist/common/dtos/BusinessDto.d.ts.map +0 -1
  40. package/dist/common/dtos/BusinessDto.js +0 -59
  41. package/dist/common/dtos/ChatDto.d.ts +0 -17
  42. package/dist/common/dtos/ChatDto.d.ts.map +0 -1
  43. package/dist/common/dtos/ChatDto.js +0 -89
  44. package/dist/common/dtos/CommonDto.d.ts +0 -13
  45. package/dist/common/dtos/CommonDto.d.ts.map +0 -1
  46. package/dist/common/dtos/CommonDto.js +0 -59
  47. package/dist/common/dtos/CommunityDto.d.ts +0 -10
  48. package/dist/common/dtos/CommunityDto.d.ts.map +0 -1
  49. package/dist/common/dtos/CommunityDto.js +0 -72
  50. package/dist/common/dtos/EventDto.d.ts +0 -24
  51. package/dist/common/dtos/EventDto.d.ts.map +0 -1
  52. package/dist/common/dtos/EventDto.js +0 -72
  53. package/dist/common/dtos/IPaginator.d.ts +0 -15
  54. package/dist/common/dtos/IPaginator.d.ts.map +0 -1
  55. package/dist/common/dtos/IPaginator.js +0 -40
  56. package/dist/common/dtos/Plan.dto.d.ts +0 -10
  57. package/dist/common/dtos/Plan.dto.d.ts.map +0 -1
  58. package/dist/common/dtos/Plan.dto.js +0 -66
  59. package/dist/common/dtos/PostDto.d.ts +0 -13
  60. package/dist/common/dtos/PostDto.d.ts.map +0 -1
  61. package/dist/common/dtos/PostDto.js +0 -75
  62. package/dist/common/dtos/ProductDto.d.ts +0 -13
  63. package/dist/common/dtos/ProductDto.d.ts.map +0 -1
  64. package/dist/common/dtos/ProductDto.js +0 -66
  65. package/dist/common/dtos/ServiceDto.d.ts +0 -19
  66. package/dist/common/dtos/ServiceDto.d.ts.map +0 -1
  67. package/dist/common/dtos/ServiceDto.js +0 -93
  68. package/dist/common/dtos/UserDto.d.ts +0 -70
  69. package/dist/common/dtos/UserDto.d.ts.map +0 -1
  70. package/dist/common/dtos/UserDto.js +0 -313
  71. package/dist/common/types/IPagination.d.ts +0 -15
  72. package/dist/common/types/IPagination.d.ts.map +0 -1
  73. package/dist/common/types/IPagination.js +0 -2
  74. package/dist/common/utils/axios.js +0 -26
  75. package/dist/common/utils/socket.js +0 -16
  76. package/dist/database/seeds/CommunityDataSeeder.js +0 -48
  77. package/dist/database/seeds/EventDataSeeder.js +0 -54
  78. package/dist/database/seeds/FeatureSeeder.js +0 -131
  79. package/dist/database/seeds/MarketplaceDataSeeder.js +0 -95
  80. package/dist/database/seeds/PlanSeeder.js +0 -78
  81. package/dist/database/seeds/UserProfileDataSeeder.js +0 -215
  82. package/dist/database/seeds/index.js +0 -39
  83. package/dist/services/StripeService.js +0 -288
  84. package/dist/services/mobile/ArticleCommentService.js +0 -479
  85. package/dist/services/mobile/ArticleService.js +0 -507
  86. package/dist/services/mobile/AuthService.js +0 -362
  87. package/dist/services/mobile/BusinessService.js +0 -267
  88. package/dist/services/mobile/BusinessServiceService.js +0 -383
  89. package/dist/services/mobile/CardService.js +0 -249
  90. package/dist/services/mobile/ChatService.js +0 -324
  91. package/dist/services/mobile/CommunityMemberService.js +0 -193
  92. package/dist/services/mobile/CommunityService.js +0 -561
  93. package/dist/services/mobile/CompleteProfileService.js +0 -308
  94. package/dist/services/mobile/ConnectionService.js +0 -338
  95. package/dist/services/mobile/EventAttendanceService.js +0 -343
  96. package/dist/services/mobile/EventService.js +0 -540
  97. package/dist/services/mobile/NotificationService.js +0 -89
  98. package/dist/services/mobile/PasswordResetService.js +0 -168
  99. package/dist/services/mobile/PlanService.js +0 -85
  100. package/dist/services/mobile/PostCommentService.js +0 -611
  101. package/dist/services/mobile/PostService.js +0 -640
  102. package/dist/services/mobile/ProductService.js +0 -360
  103. package/dist/services/mobile/RedisService.js +0 -16
  104. package/dist/services/mobile/TransactionService.js +0 -51
  105. package/dist/services/mobile/UploadService.js +0 -110
  106. package/dist/services/mobile/UserService.js +0 -128
@@ -1,479 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const typedi_1 = require("typedi");
16
- const logger_1 = require("../../common/configs/logger");
17
- const AppError_1 = require("../../common/errors/AppError");
18
- const messages_1 = require("../../common/constants/messages");
19
- const ArticleRepository_1 = require("@/repositories/ArticleRepository");
20
- const Paginator_1 = require("@/transformers/Paginator");
21
- const configs_1 = require("@/common/configs");
22
- const ArticleCommentRepository_1 = require("@/repositories/ArticleCommentRepository");
23
- const ArticleCommentResource_1 = require("@/transformers/resources/ArticleCommentResource");
24
- const IndexEnum_1 = require("@/common/enums/IndexEnum");
25
- const LikeRepository_1 = require("@/repositories/LikeRepository");
26
- const ArticleCommentModel_1 = __importDefault(require("@/models/ArticleCommentModel"));
27
- const LikeModel_1 = __importDefault(require("@/models/LikeModel"));
28
- let ArticleCommentService = class ArticleCommentService {
29
- articleRepository;
30
- articleCommentRepository;
31
- likeRepository;
32
- constructor() {
33
- this.articleRepository = new ArticleRepository_1.ArticleRepository();
34
- this.likeRepository = new LikeRepository_1.LikeRepository();
35
- this.articleCommentRepository = new ArticleCommentRepository_1.ArticleCommentRepository();
36
- }
37
- async createArticleComment(articleCommentData, user_id, article_id) {
38
- let message;
39
- const { content, } = articleCommentData;
40
- const article = await this.articleRepository.basicFindOneByConditions({
41
- uuid: article_id
42
- });
43
- if (!article) {
44
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
45
- logger_1.logger.info(message);
46
- throw new AppError_1.AppError(message, 404);
47
- }
48
- const createdArticleComment = await this.articleCommentRepository.create({
49
- content,
50
- article_id: article.id,
51
- user_id
52
- });
53
- const comment = await this.articleCommentRepository.findOneAndRelations({
54
- where: { uuid: createdArticleComment.uuid },
55
- relations: ['user']
56
- });
57
- logger_1.logger.info("Article comment created successfully");
58
- return {
59
- successful: true,
60
- data: comment ? ArticleCommentResource_1.ArticleCommentResource.toJSON(comment, user_id) : null,
61
- message: "Article comment created successfully"
62
- };
63
- }
64
- async createReplyComment(articleCommentData, user_id, comment_id) {
65
- let message;
66
- const { content, } = articleCommentData;
67
- const parentComment = await this.articleCommentRepository.basicFindOneByConditions({
68
- uuid: comment_id
69
- });
70
- if (!parentComment) {
71
- message = "We couldn't find the comment you want to reply";
72
- logger_1.logger.info(message);
73
- throw new AppError_1.AppError(message, 404);
74
- }
75
- const article = await this.articleRepository.basicFindOneByConditions({
76
- id: parentComment.article_id
77
- });
78
- if (!article) {
79
- message = "We couldn't find the article that should have owned the comment you want to reply";
80
- logger_1.logger.info(message);
81
- throw new AppError_1.AppError(message, 404);
82
- }
83
- const createdArticleComment = await this.articleCommentRepository.create({
84
- content,
85
- article_id: article.id,
86
- parent_id: parentComment.id,
87
- user_id
88
- });
89
- const comment = await this.articleCommentRepository.findOneAndRelations({
90
- where: { uuid: createdArticleComment.uuid },
91
- relations: ['user']
92
- });
93
- logger_1.logger.info("Article's comment's reply created successfully");
94
- return {
95
- successful: true,
96
- data: comment ? ArticleCommentResource_1.ArticleCommentResource.toJSON(comment, user_id) : null,
97
- message: "Article' comment's reply created successfully"
98
- };
99
- }
100
- async getComment(comment_id, user_id) {
101
- let message;
102
- const comment = await this.articleCommentRepository.findOneAndRelations({
103
- where: {
104
- uuid: comment_id
105
- },
106
- relations: ['user']
107
- });
108
- if (!comment) {
109
- message = messages_1.dynamic_messages.NOT_FOUND("Comment");
110
- logger_1.logger.info(message);
111
- throw new AppError_1.AppError(message, 404);
112
- }
113
- const article = await this.articleRepository.basicFindOneByConditions({
114
- id: comment.article_id
115
- });
116
- if (!article) {
117
- message = "We couldn't find the article that should have owned this comment";
118
- logger_1.logger.info(message);
119
- throw new AppError_1.AppError(message, 404);
120
- }
121
- const qb = this.articleCommentRepository
122
- .getRepo()
123
- .createQueryBuilder("comment")
124
- .leftJoin("comment.user", "user")
125
- .leftJoin("user.user_profile", "profile")
126
- .leftJoin("profile.avatar", "avatar")
127
- .where("comment.deleted_at IS NULL")
128
- .andWhere("comment.article_id = :articleId", { articleId: article.id })
129
- .andWhere("comment.uuid = :commentId", {
130
- commentId: comment_id,
131
- })
132
- .take(1)
133
- .orderBy("comment.created_at", "DESC");
134
- /* ======================
135
- SELECT FIELDS
136
- ====================== */
137
- qb.select([
138
- "comment.id",
139
- "comment.uuid",
140
- "comment.content",
141
- "comment.created_at",
142
- "comment.updated_at",
143
- "user.id",
144
- "user.uuid",
145
- "user.full_name",
146
- "avatar.url AS profile_image_url",
147
- ]);
148
- /* ======================
149
- REPLIES COUNT
150
- ====================== */
151
- qb.addSelect(subQuery => {
152
- return subQuery
153
- .select("COUNT(r.id)")
154
- .from(ArticleCommentModel_1.default, "r")
155
- .where("r.parent_id = comment.id")
156
- .andWhere("r.deleted_at IS NULL");
157
- }, "replies_count");
158
- // Check if user has liked the comment
159
- qb.addSelect(`
160
- EXISTS (
161
- SELECT 1
162
- FROM likes l
163
- WHERE l.likeable_id = comment.id
164
- AND l.likeable_type = :likeType
165
- AND l.user_id = :user_id
166
- AND l.deleted_at IS NULL
167
- )
168
- `, "has_liked")
169
- .setParameter("likeType", IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL)
170
- .setParameter("user_id", user_id);
171
- /* ======================
172
- LIKES COUNT (COMMENT)
173
- ====================== */
174
- qb.addSelect(subQuery => {
175
- return subQuery
176
- .select("COUNT(l.id)")
177
- .from(LikeModel_1.default, "l")
178
- .where("l.likeable_id = comment.id")
179
- .andWhere("l.likeable_type = :commentType")
180
- .andWhere("l.deleted_at IS NULL");
181
- }, "likes_count")
182
- .setParameter("commentType", IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL);
183
- const { entities, raw } = await qb.getRawAndEntities();
184
- const foundComment = entities[0];
185
- const { uuid, content, created_at, updated_at, user } = foundComment;
186
- const data = {
187
- uuid,
188
- content,
189
- created_at,
190
- updated_at,
191
- creator: {
192
- uuid: user?.uuid,
193
- full_name: user?.full_name,
194
- profile_image_url: raw[0]?.profile_image_url,
195
- },
196
- replies_count: raw[0]?.replies_count,
197
- likes_count: raw[0]?.likes_count,
198
- has_liked: raw[0]?.has_liked,
199
- };
200
- return {
201
- successful: true,
202
- data,
203
- message: "Comment fetched successfully!"
204
- };
205
- }
206
- async likeOrUnlikeComment(comment_id, user_id) {
207
- let message;
208
- const comment = await this.articleCommentRepository.basicFindOneByConditions({
209
- uuid: comment_id
210
- });
211
- if (!comment) {
212
- message = "We couldn't find the comment you want to like/unlike";
213
- logger_1.logger.info(message);
214
- throw new AppError_1.AppError(message, 404);
215
- }
216
- const article = await this.articleRepository.basicFindOneByConditions({
217
- id: comment.article_id
218
- });
219
- if (!article) {
220
- message = "We couldn't find the article that should have owned the comment you want to like/unlike";
221
- logger_1.logger.info(message);
222
- throw new AppError_1.AppError(message, 404);
223
- }
224
- const alreadyLikedComment = await this.likeRepository.basicFindOneByConditions({
225
- likeable_id: comment.id,
226
- likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL,
227
- user_id
228
- });
229
- if (alreadyLikedComment) {
230
- // Unlike the comment
231
- await this.likeRepository.deleteByCondition({
232
- user_id,
233
- likeable_id: comment.id,
234
- likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL
235
- });
236
- message = "Comment unliked successfully";
237
- }
238
- else {
239
- // Like the comment
240
- await this.likeRepository.create({
241
- user_id,
242
- likeable_id: comment.id,
243
- likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL
244
- });
245
- message = "Comment liked successfully";
246
- }
247
- return {
248
- successful: true,
249
- data: null,
250
- message
251
- };
252
- }
253
- async getArticleComments(user_id, article_id, pageNumber) {
254
- let message;
255
- const page_number = pageNumber || 1;
256
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
257
- const article = await this.articleRepository.basicFindOneByConditions({
258
- uuid: article_id
259
- });
260
- if (!article) {
261
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
262
- logger_1.logger.info(message);
263
- throw new AppError_1.AppError(message, 404);
264
- }
265
- const paginationDto = {
266
- page_number, limit
267
- };
268
- const { data, total, perPage, page } = await this.articleCommentRepository.getPagedArticleComments(paginationDto, article.id, user_id);
269
- const { entities, raw } = data;
270
- const articleCommentEntities = entities;
271
- const rawArticleComments = raw;
272
- const articleComments = articleCommentEntities.map((entity, index) => {
273
- const { uuid, content, created_at, updated_at, user } = entity;
274
- return {
275
- uuid,
276
- content,
277
- created_at,
278
- updated_at,
279
- creator: {
280
- uuid: user?.uuid,
281
- full_name: user?.full_name,
282
- profile_image_url: rawArticleComments[index]?.profile_image_url,
283
- },
284
- replies_count: rawArticleComments[index]?.replies_count,
285
- likes_count: rawArticleComments[index]?.likes_count,
286
- has_liked: rawArticleComments[index]?.has_liked,
287
- };
288
- });
289
- const pagedArticleComments = (0, Paginator_1.paginator)({
290
- total,
291
- perPage,
292
- currentPage: page_number,
293
- data: articleComments,
294
- });
295
- return {
296
- successful: true,
297
- data: pagedArticleComments,
298
- message: "Comments fetched successfully!"
299
- };
300
- }
301
- async getCommentReplies(user_id, comment_id, pageNumber) {
302
- let message;
303
- const page_number = pageNumber || 1;
304
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
305
- const parentComment = await this.articleCommentRepository.basicFindOneByConditions({
306
- uuid: comment_id
307
- });
308
- if (!parentComment) {
309
- message = messages_1.dynamic_messages.NOT_FOUND("Comment");
310
- logger_1.logger.info(message);
311
- throw new AppError_1.AppError(message, 404);
312
- }
313
- const article = await this.articleRepository.basicFindOneByConditions({
314
- id: parentComment.article_id
315
- });
316
- if (!article) {
317
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
318
- logger_1.logger.info(message);
319
- throw new AppError_1.AppError(message, 404);
320
- }
321
- const paginationDto = {
322
- page_number,
323
- limit
324
- };
325
- const { data, total, perPage, page } = await this.articleCommentRepository.getPagedCommentReplies(paginationDto, parentComment.id, user_id);
326
- const { entities, raw } = data;
327
- const articleCommentEntities = entities;
328
- const rawArticleComments = raw;
329
- const articleComments = articleCommentEntities.map((entity, index) => {
330
- const { uuid, content, created_at, updated_at, user } = entity;
331
- return {
332
- uuid,
333
- content,
334
- created_at,
335
- updated_at,
336
- creator: {
337
- uuid: user?.uuid,
338
- full_name: user?.full_name,
339
- profile_image_url: rawArticleComments[index]?.profile_image_url,
340
- },
341
- replies_count: rawArticleComments[index]?.replies_count,
342
- likes_count: rawArticleComments[index]?.likes_count,
343
- has_liked: rawArticleComments[index]?.has_liked,
344
- };
345
- });
346
- const pagedArticleComments = (0, Paginator_1.paginator)({
347
- total,
348
- perPage,
349
- currentPage: page_number,
350
- data: articleComments,
351
- });
352
- return {
353
- successful: true,
354
- data: pagedArticleComments,
355
- message: "Comments fetched successfully!"
356
- };
357
- }
358
- async getCommentLikes(user_id, comment_id, pageNumber) {
359
- let message;
360
- const page_number = pageNumber || 1;
361
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
362
- const comment = await this.articleCommentRepository.basicFindOneByConditions({
363
- uuid: comment_id
364
- });
365
- if (!comment) {
366
- message = messages_1.dynamic_messages.NOT_FOUND("Comment");
367
- logger_1.logger.info(message);
368
- throw new AppError_1.AppError(message, 404);
369
- }
370
- const article = await this.articleRepository.basicFindOneByConditions({
371
- id: comment.article_id
372
- });
373
- if (!article) {
374
- message = messages_1.dynamic_messages.NOT_FOUND("Article");
375
- logger_1.logger.info(message);
376
- throw new AppError_1.AppError(message, 404);
377
- }
378
- const paginationDto = {
379
- page_number,
380
- metadata: {
381
- comment_id: comment.id
382
- },
383
- limit
384
- };
385
- const { data, total, perPage, page } = await this.likeRepository.getPagedCommentUserLikes(paginationDto, user_id);
386
- const { entities, raw } = data;
387
- const commentUserLikes = raw.map((like) => {
388
- return {
389
- user: {
390
- name: like?.user_full_name,
391
- uuid: like?.user_uuid,
392
- avatar_url: like?.avatar_url,
393
- },
394
- liked_at: like?.like_created_at
395
- };
396
- });
397
- const pagedCommentLikes = (0, Paginator_1.paginator)({
398
- total,
399
- perPage,
400
- currentPage: page_number,
401
- data: commentUserLikes,
402
- });
403
- return {
404
- successful: true,
405
- data: pagedCommentLikes,
406
- message: "Comment likes fetched successfully!"
407
- };
408
- }
409
- async updateOneComment(articleCommentData, comment_id, user_id) {
410
- let message;
411
- const { content } = articleCommentData;
412
- const comment = await this.articleCommentRepository.findOneAndRelations({
413
- where: {
414
- uuid: comment_id,
415
- user_id
416
- }
417
- });
418
- if (!comment) {
419
- message = "We couldn't find the comment you want to update";
420
- logger_1.logger.info(message);
421
- throw new AppError_1.AppError(message, 404);
422
- }
423
- const article = await this.articleRepository.basicFindOneByConditions({
424
- id: comment.article_id
425
- });
426
- if (!article) {
427
- message = "We couldn't find the article that should have owned the comment you want to update";
428
- logger_1.logger.info(message);
429
- throw new AppError_1.AppError(message, 404);
430
- }
431
- const updatedComment = await this.articleCommentRepository.updateOne({
432
- uuid: comment.uuid,
433
- user_id,
434
- }, {
435
- content
436
- });
437
- return {
438
- successful: true,
439
- data: updatedComment,
440
- message: "Comment updated successfully!"
441
- };
442
- }
443
- async deleteOneComment(comment_id, user_id) {
444
- let message;
445
- const comment = await this.articleCommentRepository.findOneAndRelations({
446
- where: {
447
- uuid: comment_id,
448
- user_id
449
- }
450
- });
451
- if (!comment) {
452
- message = "We couldn't find the comment you want to delete";
453
- logger_1.logger.info(message);
454
- throw new AppError_1.AppError(message, 404);
455
- }
456
- const article = await this.articleRepository.basicFindOneByConditions({
457
- id: comment.article_id
458
- });
459
- if (!article) {
460
- message = "We couldn't find the article that should have owned the comment you want to delete";
461
- logger_1.logger.info(message);
462
- throw new AppError_1.AppError(message, 404);
463
- }
464
- await this.articleCommentRepository.deleteByCondition({
465
- uuid: comment.uuid,
466
- user_id,
467
- });
468
- return {
469
- successful: true,
470
- data: null,
471
- message: "Comment deleted successfully!"
472
- };
473
- }
474
- };
475
- ArticleCommentService = __decorate([
476
- (0, typedi_1.Service)(),
477
- __metadata("design:paramtypes", [])
478
- ], ArticleCommentService);
479
- exports.default = ArticleCommentService;