@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,324 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const typedi_1 = require("typedi");
13
- const Paginator_1 = require("@/transformers/Paginator");
14
- const configs_1 = require("@/common/configs");
15
- const ChatMessageRepository_1 = require("@/repositories/ChatMessageRepository");
16
- const AppError_1 = require("@/common/errors/AppError");
17
- const UserRepository_1 = require("@/repositories/UserRepository");
18
- const logger_1 = require("@/common/configs/logger");
19
- const messages_1 = require("@/common/constants/messages");
20
- const ConversationRepository_1 = require("@/repositories/ConversationRepository");
21
- const ChatEnum_1 = require("@/common/enums/ChatEnum");
22
- const typeorm_1 = require("typeorm");
23
- const NotificationEnum_1 = require("@/common/enums/NotificationEnum");
24
- const IndexEnum_1 = require("@/common/enums/IndexEnum");
25
- const NotificationRepository_1 = require("@/repositories/NotificationRepository");
26
- // import { ChatRepository } from "@/repositories/ChatRepository";
27
- // import { ChatCollection } from "@/transformers/collections/ChatCollection";
28
- let ChatService = class ChatService {
29
- chatMessageRepository;
30
- notificationRepository;
31
- conversationRepository;
32
- userRepository;
33
- constructor() {
34
- this.notificationRepository = new NotificationRepository_1.NotificationRepository();
35
- this.chatMessageRepository = new ChatMessageRepository_1.ChatMessageRepository();
36
- this.conversationRepository = new ConversationRepository_1.ConversationRepository();
37
- this.userRepository = new UserRepository_1.UserRepository();
38
- }
39
- async joinChat(user_id, user_to_join_id) {
40
- if (!user_to_join_id) {
41
- throw new AppError_1.AppError("You need to provide the ID of the user you want start or continue a chat with", 422);
42
- }
43
- let message;
44
- const authUser = await this.userRepository.basicFindOneByConditions({
45
- uuid: user_id
46
- });
47
- if (!authUser) {
48
- message = messages_1.dynamic_messages.NOT_FOUND("Auth User");
49
- logger_1.logger.info(message);
50
- throw new AppError_1.AppError(message, 404);
51
- }
52
- const otherUser = await this.userRepository.basicFindOneByConditions({
53
- uuid: user_to_join_id
54
- });
55
- if (!otherUser) {
56
- message = messages_1.dynamic_messages.NOT_FOUND("User");
57
- logger_1.logger.info(message);
58
- throw new AppError_1.AppError(message, 404);
59
- }
60
- let conversation = await this.conversationRepository.getRepo()
61
- .createQueryBuilder("c")
62
- .leftJoinAndSelect("c.participants", "p")
63
- .where("p.id IN (:...ids)", { ids: [authUser.id, otherUser.id] })
64
- .getOne();
65
- if (!conversation) {
66
- conversation = await this.conversationRepository.create({ participants: [authUser, otherUser] });
67
- }
68
- return {
69
- successful: true,
70
- data: {
71
- ...conversation
72
- },
73
- message: `Chat joined successfully`
74
- };
75
- }
76
- async sendMessage(authUserId, conversation_id, message_body) {
77
- if (!conversation_id) {
78
- throw new AppError_1.AppError("You need to provide the ID of the conversation you want to send a message to", 422);
79
- }
80
- let message;
81
- const foundConversation = await this.conversationRepository.getRepo()
82
- .createQueryBuilder("c")
83
- .leftJoinAndSelect("c.participants", "p")
84
- .where("c.uuid = :conversation_id", { conversation_id })
85
- .andWhere("p.id = :authUserId", { authUserId })
86
- .getOne();
87
- if (!foundConversation) {
88
- message = messages_1.dynamic_messages.NOT_FOUND("Conversation");
89
- logger_1.logger.info(message);
90
- throw new AppError_1.AppError(message, 404);
91
- }
92
- const sentMessage = await this.chatMessageRepository.create({
93
- text: message_body,
94
- sender_id: authUserId,
95
- sent_at: new Date(),
96
- conversation_id: foundConversation.id,
97
- });
98
- const connectionReceiver = foundConversation?.participants[0];
99
- await this.notificationRepository.save({
100
- user_id: connectionReceiver.id,
101
- type: NotificationEnum_1.NotificationType.NEW_CHAT_MESSAGE,
102
- message: `You have a new message from ${connectionReceiver.full_name}`,
103
- notifiable_id: sentMessage.id,
104
- notifiable_type: IndexEnum_1.SYS_MODELS.CHAT_MESSAGE_MODEL,
105
- });
106
- return {
107
- successful: true,
108
- data: {
109
- ...sentMessage,
110
- conversation_id: foundConversation.uuid,
111
- },
112
- message: `Message sent successfully`
113
- };
114
- }
115
- async readMessage(authUserId, conversation_id, message_id) {
116
- if (!conversation_id) {
117
- throw new AppError_1.AppError("You need to provide the ID of the conversation you want to read a message from", 422);
118
- }
119
- let message;
120
- const foundConversation = await this.conversationRepository.getRepo()
121
- .createQueryBuilder("c")
122
- .leftJoin("c.participants", "p")
123
- .where("c.uuid = :conversation_id", { conversation_id })
124
- .andWhere("p.id = :authUserId", { authUserId })
125
- .getOne();
126
- if (!foundConversation) {
127
- message = messages_1.dynamic_messages.NOT_FOUND("Conversation");
128
- logger_1.logger.info(message);
129
- throw new AppError_1.AppError(message, 404);
130
- }
131
- const foundMessage = await this.chatMessageRepository.basicFindOneByConditions({
132
- uuid: message_id
133
- });
134
- if (!foundMessage) {
135
- message = messages_1.dynamic_messages.NOT_FOUND("Message");
136
- logger_1.logger.info(message);
137
- throw new AppError_1.AppError(message, 404);
138
- }
139
- if (foundMessage.sender_id !== authUserId) {
140
- await this.chatMessageRepository.updateOne({
141
- uuid: message_id,
142
- conversation_id: foundConversation.id
143
- }, {
144
- read_at: new Date(),
145
- status: ChatEnum_1.MessageStatus.READ
146
- });
147
- }
148
- return {
149
- successful: true,
150
- data: {
151
- ...foundMessage,
152
- conversation_id: foundConversation.uuid,
153
- },
154
- message: `Message read successfully`
155
- };
156
- }
157
- async deliveredMessage(authUserId, conversation_id, message_id) {
158
- if (!conversation_id) {
159
- throw new AppError_1.AppError("You need to provide the ID of the conversation.", 422);
160
- }
161
- let message;
162
- const foundConversation = await this.conversationRepository.getRepo()
163
- .createQueryBuilder("c")
164
- .leftJoin("c.participants", "p")
165
- .where("c.uuid = :conversation_id", { conversation_id })
166
- .andWhere("p.id = :authUserId", { authUserId })
167
- .getOne();
168
- if (!foundConversation) {
169
- message = messages_1.dynamic_messages.NOT_FOUND("Conversation");
170
- logger_1.logger.info(message);
171
- throw new AppError_1.AppError(message, 404);
172
- }
173
- const foundMessage = await this.chatMessageRepository.basicFindOneByConditions({
174
- uuid: message_id
175
- });
176
- if (!foundMessage) {
177
- message = messages_1.dynamic_messages.NOT_FOUND("Message");
178
- logger_1.logger.info(message);
179
- throw new AppError_1.AppError(message, 404);
180
- }
181
- if (foundMessage.sender_id !== authUserId) {
182
- await this.chatMessageRepository.updateOne({
183
- uuid: message_id,
184
- conversation_id: foundConversation.id
185
- }, {
186
- delivered_at: new Date(),
187
- status: ChatEnum_1.MessageStatus.DELIVERED
188
- });
189
- }
190
- return {
191
- successful: true,
192
- data: {
193
- ...foundMessage,
194
- conversation_id: foundConversation.uuid,
195
- },
196
- message: `Message delivered successfully`
197
- };
198
- }
199
- async loadConversations(authUserId, conversation_id, pageNumber) {
200
- if (!conversation_id) {
201
- throw new AppError_1.AppError("You need to provide the ID of the conversation.", 422);
202
- }
203
- let message;
204
- const foundConversation = await this.conversationRepository.getRepo()
205
- .createQueryBuilder("c")
206
- .leftJoin("c.participants", "p")
207
- .where("c.uuid = :conversation_id", { conversation_id })
208
- .andWhere("p.id = :authUserId", { authUserId })
209
- .getOne();
210
- if (!foundConversation) {
211
- message = messages_1.dynamic_messages.NOT_FOUND("Conversation");
212
- logger_1.logger.info(message);
213
- throw new AppError_1.AppError(message, 404);
214
- }
215
- const page_number = pageNumber || 1;
216
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
217
- const dataFetchParams = {
218
- page_number,
219
- limit
220
- };
221
- const { data, total, perPage, page } = await this.conversationRepository.getPagedConversations(dataFetchParams);
222
- const { raw, entities } = data;
223
- const messages = (0, Paginator_1.paginator)({
224
- total: total,
225
- perPage: perPage,
226
- currentPage: page,
227
- data: entities,
228
- });
229
- // Set as delivered
230
- await this.chatMessageRepository.getRepo().update({
231
- conversation_id: foundConversation.id,
232
- status: ChatEnum_1.MessageStatus.SENT,
233
- sender_id: (0, typeorm_1.Not)(authUserId)
234
- }, {
235
- delivered_at: new Date(),
236
- status: ChatEnum_1.MessageStatus.DELIVERED
237
- });
238
- // Set as read
239
- await this.chatMessageRepository.getRepo().update({
240
- conversation_id: foundConversation.id,
241
- sender_id: (0, typeorm_1.Not)(authUserId),
242
- status: ChatEnum_1.MessageStatus.DELIVERED
243
- }, {
244
- read_at: new Date(),
245
- status: ChatEnum_1.MessageStatus.READ
246
- });
247
- return {
248
- successful: true,
249
- data: messages,
250
- message: `Messages fetched successfully`
251
- };
252
- }
253
- async updateMessage(authUserId, message_id, message_body) {
254
- if (!message_id) {
255
- throw new AppError_1.AppError("You need to provide the ID of the message you want to update", 422);
256
- }
257
- let message;
258
- const foundMessage = await this.chatMessageRepository.basicFindOneByConditions({
259
- uuid: message_id
260
- });
261
- if (!foundMessage) {
262
- message = messages_1.dynamic_messages.NOT_FOUND("Message");
263
- logger_1.logger.info(message);
264
- throw new AppError_1.AppError(message, 404);
265
- }
266
- if (foundMessage.sender_id !== authUserId) {
267
- message = "You are not authorized to update this message";
268
- logger_1.logger.error(message);
269
- throw new AppError_1.AppError(message, 403);
270
- }
271
- await this.chatMessageRepository.updateOne({
272
- uuid: message_id,
273
- sender_id: authUserId
274
- }, {
275
- read_at: null,
276
- sent_at: new Date(),
277
- delivered_at: null,
278
- text: message_body,
279
- status: ChatEnum_1.MessageStatus.SENT
280
- });
281
- return {
282
- successful: true,
283
- data: {
284
- ...foundMessage,
285
- },
286
- message: `Message updated successfully`
287
- };
288
- }
289
- async deleteMessage(authUserId, message_id) {
290
- if (!message_id) {
291
- throw new AppError_1.AppError("You need to provide the ID of the message you want to update", 422);
292
- }
293
- let message;
294
- const foundMessage = await this.chatMessageRepository.basicFindOneByConditions({
295
- uuid: message_id
296
- });
297
- if (!foundMessage) {
298
- message = messages_1.dynamic_messages.NOT_FOUND("Message");
299
- logger_1.logger.info(message);
300
- throw new AppError_1.AppError(message, 404);
301
- }
302
- if (foundMessage.sender_id !== authUserId) {
303
- message = "You are not authorized to delete this message";
304
- logger_1.logger.error(message);
305
- throw new AppError_1.AppError(message, 403);
306
- }
307
- await this.chatMessageRepository.deleteByCondition({
308
- uuid: message_id,
309
- sender_id: authUserId
310
- });
311
- return {
312
- successful: true,
313
- data: {
314
- ...foundMessage,
315
- },
316
- message: `Message deleted successfully`
317
- };
318
- }
319
- };
320
- ChatService = __decorate([
321
- (0, typedi_1.Service)(),
322
- __metadata("design:paramtypes", [])
323
- ], ChatService);
324
- exports.default = ChatService;
@@ -1,193 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const typedi_1 = require("typedi");
13
- const logger_1 = require("../../common/configs/logger");
14
- const AppError_1 = require("../../common/errors/AppError");
15
- const messages_1 = require("../../common/constants/messages");
16
- const CommunityRepository_1 = require("@/repositories/CommunityRepository");
17
- const Paginator_1 = require("@/transformers/Paginator");
18
- const configs_1 = require("@/common/configs");
19
- const CommunityMemberRepository_1 = require("@/repositories/CommunityMemberRepository");
20
- let CommunityMemberService = class CommunityMemberService {
21
- communityRepository;
22
- communityMemberRepository;
23
- constructor() {
24
- this.communityRepository = new CommunityRepository_1.CommunityRepository();
25
- this.communityMemberRepository = new CommunityMemberRepository_1.CommunityMemberRepository();
26
- }
27
- async joinCommunity(community_id, user_id) {
28
- let message;
29
- const community = await this.communityRepository.basicFindOneByConditions({
30
- uuid: community_id
31
- });
32
- if (!community) {
33
- message = messages_1.dynamic_messages.NOT_FOUND("Community");
34
- logger_1.logger.info(message);
35
- throw new AppError_1.AppError(message, 404);
36
- }
37
- const alreadyMember = await this.communityMemberRepository.getRepo().findOne({
38
- where: {
39
- community_id: community.id,
40
- member_id: user_id
41
- }
42
- });
43
- if (!alreadyMember) {
44
- await this.communityMemberRepository.create({
45
- community_id: community.id,
46
- member_id: user_id
47
- });
48
- }
49
- return {
50
- successful: true,
51
- data: null,
52
- message: `You successfully joined '${community.name}' community`
53
- };
54
- }
55
- async leaveCommunity(community_id, user_id) {
56
- let message;
57
- const community = await this.communityRepository.basicFindOneByConditions({
58
- uuid: community_id
59
- });
60
- if (!community) {
61
- message = messages_1.dynamic_messages.NOT_FOUND("Community");
62
- logger_1.logger.info(message);
63
- throw new AppError_1.AppError(message, 404);
64
- }
65
- if (community.user_id === user_id) {
66
- message = "You cannot leave an community you created";
67
- logger_1.logger.info(message);
68
- throw new AppError_1.AppError(message, 404);
69
- }
70
- const alreadyMember = await this.communityMemberRepository.getRepo().findOne({
71
- where: {
72
- community_id: community.id,
73
- member_id: user_id
74
- }
75
- });
76
- if (!alreadyMember) {
77
- message = `You are not attending community ${community.name}`;
78
- logger_1.logger.info(message);
79
- throw new AppError_1.AppError(message, 404);
80
- }
81
- await this.communityMemberRepository.deleteByCondition({
82
- community_id: community.id,
83
- member_id: user_id
84
- });
85
- return {
86
- successful: true,
87
- data: null,
88
- message: `You successfully left '${community.name}' community`
89
- };
90
- }
91
- async communitiesIamMember(user_id, pageNumber) {
92
- let message;
93
- const page_number = pageNumber || 1;
94
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
95
- const paginationDto = {
96
- page_number, limit
97
- };
98
- const { data, total, perPage, page } = await this.communityRepository.getPagedCommunityMembers(paginationDto, user_id);
99
- const { entities, raw } = data;
100
- const communityEntities = entities;
101
- const rawCommunities = raw;
102
- if (!communityEntities || !rawCommunities) {
103
- message = messages_1.dynamic_messages.NOT_FOUND("Communities");
104
- logger_1.logger.info(message);
105
- throw new AppError_1.AppError(message, 404);
106
- }
107
- const communityCollections = communityEntities.map((communityEntity, index) => {
108
- const { uuid, visibility, created_at, name, description, user } = communityEntity;
109
- return {
110
- uuid,
111
- created_at,
112
- name,
113
- visibility,
114
- description,
115
- creator: {
116
- uuid: user?.uuid,
117
- full_name: user?.full_name,
118
- avatar_url: rawCommunities[index]?.creator_avatar_url,
119
- },
120
- community_cover_image_url: rawCommunities[index]?.cover_image_url,
121
- community_profile_image_url: rawCommunities[index]?.profile_image_url,
122
- members_count: rawCommunities[index]?.members_count,
123
- new_members_this_week: rawCommunities[index]?.new_members_this_week,
124
- community_topics: rawCommunities[index]?.community_topics,
125
- posts_count: rawCommunities[index]?.posts_count,
126
- last_members: rawCommunities[index]?.last_members,
127
- };
128
- });
129
- const pagedCommunities = (0, Paginator_1.paginator)({
130
- total,
131
- perPage,
132
- currentPage: page,
133
- data: communityCollections
134
- });
135
- return {
136
- successful: true,
137
- data: pagedCommunities,
138
- message: "Communities I am a member fetched successfully!"
139
- };
140
- }
141
- async communityMembers(community_id, user_id, pageNumber) {
142
- let message;
143
- const page_number = pageNumber || 1;
144
- const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
145
- const foundCommunity = await this.communityRepository.basicFindOneByConditions({
146
- uuid: community_id
147
- });
148
- if (!foundCommunity) {
149
- message = messages_1.dynamic_messages.NOT_FOUND("Community");
150
- logger_1.logger.info(message);
151
- throw new AppError_1.AppError(message);
152
- }
153
- const { data, total, page, perPage } = await this.communityMemberRepository.getPagedMembersInCommunity({
154
- page_number,
155
- limit
156
- }, foundCommunity.id);
157
- const { entities, raw } = data;
158
- const attendanceEntities = entities;
159
- const rawAttendance = raw;
160
- const attendance = rawAttendance.map((attendanceEntity, index) => {
161
- const { cm_id, cm_created_at, community_created_at, user_id, uuid, full_name, email, joined_at, profile_image_uuid, profile_image_url } = attendanceEntity;
162
- return {
163
- created_at: cm_created_at,
164
- uuid,
165
- full_name,
166
- joined_at,
167
- profile_image_uuid,
168
- profile_image_url,
169
- };
170
- });
171
- const communityAttendance = (0, Paginator_1.paginator)({
172
- total,
173
- perPage,
174
- currentPage: page,
175
- data: attendance, //CommunityCollection.toJSON(attendance?.data, userId),
176
- });
177
- if (!communityAttendance) {
178
- message = messages_1.dynamic_messages.NOT_FOUND("CommunityAttendance");
179
- logger_1.logger.info(message);
180
- throw new AppError_1.AppError(message, 404);
181
- }
182
- return {
183
- successful: true,
184
- data: communityAttendance,
185
- message: "Community members fetched successfully!"
186
- };
187
- }
188
- };
189
- CommunityMemberService = __decorate([
190
- (0, typedi_1.Service)(),
191
- __metadata("design:paramtypes", [])
192
- ], CommunityMemberService);
193
- exports.default = CommunityMemberService;