@builder6/rooms 0.10.8 → 0.11.0

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 (112) hide show
  1. package/dist/emails/UnreadMention.d.ts +9 -0
  2. package/dist/emails/UnreadMention.js +54 -0
  3. package/dist/emails/UnreadMention.js.map +1 -0
  4. package/dist/emails/UnreadReplies.d.ts +9 -0
  5. package/dist/emails/UnreadReplies.js +68 -0
  6. package/dist/emails/UnreadReplies.js.map +1 -0
  7. package/dist/emails/_components/comment.d.ts +1 -0
  8. package/dist/emails/_components/comment.js +32 -0
  9. package/dist/emails/_components/comment.js.map +1 -0
  10. package/dist/emails/_components/header.d.ts +2 -0
  11. package/dist/emails/_components/header.js +15 -0
  12. package/dist/emails/_components/header.js.map +1 -0
  13. package/dist/emails/_components/headline.d.ts +5 -0
  14. package/dist/emails/_components/headline.js +17 -0
  15. package/dist/emails/_components/headline.js.map +1 -0
  16. package/dist/emails/_components/layout.d.ts +5 -0
  17. package/dist/emails/_components/layout.js +24 -0
  18. package/dist/emails/_components/layout.js.map +1 -0
  19. package/dist/emails/_lib/types.d.ts +9 -0
  20. package/dist/emails/_lib/types.js +3 -0
  21. package/dist/emails/_lib/types.js.map +1 -0
  22. package/dist/emails/_styles/colors.d.ts +2 -0
  23. package/dist/emails/_styles/colors.js +7 -0
  24. package/dist/emails/_styles/colors.js.map +1 -0
  25. package/dist/emails/_utils/cn.d.ts +2 -0
  26. package/dist/emails/_utils/cn.js +10 -0
  27. package/dist/emails/_utils/cn.js.map +1 -0
  28. package/dist/emails/_utils/comments.d.ts +7 -0
  29. package/dist/emails/_utils/comments.js +29 -0
  30. package/dist/emails/_utils/comments.js.map +1 -0
  31. package/dist/emails/_utils/getProps.d.ts +1 -0
  32. package/dist/emails/_utils/getProps.js +11 -0
  33. package/dist/emails/_utils/getProps.js.map +1 -0
  34. package/dist/rooms/app.controller.d.ts +3 -1
  35. package/dist/rooms/app.controller.js +61 -46
  36. package/dist/rooms/app.controller.js.map +1 -1
  37. package/dist/rooms/emailNotification.service.d.ts +17 -0
  38. package/dist/rooms/emailNotification.service.js +113 -0
  39. package/dist/rooms/emailNotification.service.js.map +1 -0
  40. package/dist/rooms/emails/comment-body.d.ts +44 -0
  41. package/dist/rooms/emails/comment-body.js +138 -0
  42. package/dist/rooms/emails/comment-body.js.map +1 -0
  43. package/dist/rooms/emails/comment-with-body.d.ts +6 -0
  44. package/dist/rooms/emails/comment-with-body.js +17 -0
  45. package/dist/rooms/emails/comment-with-body.js.map +1 -0
  46. package/dist/rooms/emails/index.d.ts +4 -0
  47. package/dist/rooms/emails/index.js +7 -0
  48. package/dist/rooms/emails/index.js.map +1 -0
  49. package/dist/rooms/emails/lib/batch-users-resolver.d.ts +9 -0
  50. package/dist/rooms/emails/lib/batch-users-resolver.js +67 -0
  51. package/dist/rooms/emails/lib/batch-users-resolver.js.map +1 -0
  52. package/dist/rooms/emails/lib/css-properties.d.ts +3 -0
  53. package/dist/rooms/emails/lib/css-properties.js +96 -0
  54. package/dist/rooms/emails/lib/css-properties.js.map +1 -0
  55. package/dist/rooms/emails/lib/warning.d.ts +1 -0
  56. package/dist/rooms/emails/lib/warning.js +20 -0
  57. package/dist/rooms/emails/lib/warning.js.map +1 -0
  58. package/dist/rooms/emails/thread-notification.d.ts +90 -0
  59. package/dist/rooms/emails/thread-notification.js +297 -0
  60. package/dist/rooms/emails/thread-notification.js.map +1 -0
  61. package/dist/rooms/globals/augmentation.d.ts +0 -5
  62. package/dist/rooms/lib/utils.js +21 -10
  63. package/dist/rooms/lib/utils.js.map +1 -1
  64. package/dist/rooms/liveblocks.service.d.ts +16 -0
  65. package/dist/rooms/liveblocks.service.js +54 -0
  66. package/dist/rooms/liveblocks.service.js.map +1 -0
  67. package/dist/rooms/notifications.service.d.ts +4 -0
  68. package/dist/rooms/notifications.service.js +107 -80
  69. package/dist/rooms/notifications.service.js.map +1 -1
  70. package/dist/rooms/rooms.controller.d.ts +5 -3
  71. package/dist/rooms/rooms.controller.js +321 -243
  72. package/dist/rooms/rooms.controller.js.map +1 -1
  73. package/dist/rooms/rooms.gateway.js +132 -109
  74. package/dist/rooms/rooms.gateway.js.map +1 -1
  75. package/dist/rooms/rooms.guard.js +31 -19
  76. package/dist/rooms/rooms.guard.js.map +1 -1
  77. package/dist/rooms/rooms.module.js +10 -1
  78. package/dist/rooms/rooms.module.js.map +1 -1
  79. package/dist/rooms/rooms.moleculer.js +85 -66
  80. package/dist/rooms/rooms.moleculer.js.map +1 -1
  81. package/dist/rooms/rooms.service.d.ts +17 -4
  82. package/dist/rooms/rooms.service.js +408 -340
  83. package/dist/rooms/rooms.service.js.map +1 -1
  84. package/package.json +18 -7
  85. package/src/emails/UnreadMention.tsx +76 -0
  86. package/src/emails/UnreadReplies.tsx +106 -0
  87. package/src/emails/_components/comment.tsx +70 -0
  88. package/src/emails/_components/header.tsx +27 -0
  89. package/src/emails/_components/headline.tsx +20 -0
  90. package/src/emails/_components/layout.tsx +45 -0
  91. package/src/emails/_lib/types.ts +10 -0
  92. package/src/emails/_styles/colors.ts +7 -0
  93. package/src/emails/_utils/cn.ts +6 -0
  94. package/src/emails/_utils/comments.ts +61 -0
  95. package/src/emails/_utils/getProps.ts +7 -0
  96. package/src/rooms/app.controller.ts +7 -2
  97. package/src/rooms/emailNotification.service.tsx +152 -0
  98. package/src/rooms/emails/comment-body.tsx +342 -0
  99. package/src/rooms/emails/comment-with-body.ts +24 -0
  100. package/src/rooms/emails/index.ts +25 -0
  101. package/src/rooms/emails/lib/batch-users-resolver.ts +120 -0
  102. package/src/rooms/emails/lib/css-properties.ts +123 -0
  103. package/src/rooms/emails/lib/warning.ts +25 -0
  104. package/src/rooms/emails/thread-notification.tsx +583 -0
  105. package/src/rooms/globals/augmentation.ts +8 -8
  106. package/src/rooms/liveblocks.service.ts +25 -0
  107. package/src/rooms/notifications.service.ts +22 -10
  108. package/src/rooms/rooms.controller.ts +22 -4
  109. package/src/rooms/rooms.module.ts +10 -1
  110. package/src/rooms/rooms.service.ts +35 -20
  111. package/tsconfig.json +2 -0
  112. package/yarn-error.log +17218 -0
@@ -11,12 +11,22 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
14
23
  Object.defineProperty(exports, "__esModule", { value: true });
15
24
  exports.RoomsController = void 0;
16
25
  const core_1 = require("@builder6/core");
17
26
  const files_1 = require("@builder6/files");
18
27
  const rooms_service_1 = require("./rooms.service");
19
28
  const lodash_1 = require("lodash");
29
+ const swagger_1 = require("@nestjs/swagger");
20
30
  const common_1 = require("@nestjs/common");
21
31
  const jwt_1 = require("@nestjs/jwt");
22
32
  const rooms_guard_1 = require("./rooms.guard");
@@ -24,292 +34,347 @@ const rawBody = require("raw-body");
24
34
  const rooms_gateway_1 = require("./rooms.gateway");
25
35
  const ServerMsg_1 = require("./protocol/ServerMsg");
26
36
  const notifications_service_1 = require("./notifications.service");
37
+ const emailNotification_service_1 = require("./emailNotification.service");
27
38
  let RoomsController = class RoomsController {
28
- constructor(roomsService, filesService, jwtService, roomsGateway, notificationsService) {
39
+ constructor(roomsService, filesService, jwtService, roomsGateway, notificationsService, emailNotificationService) {
29
40
  this.roomsService = roomsService;
30
41
  this.filesService = filesService;
31
42
  this.jwtService = jwtService;
32
43
  this.roomsGateway = roomsGateway;
33
44
  this.notificationsService = notificationsService;
45
+ this.emailNotificationService = emailNotificationService;
34
46
  }
35
- async getToken(body, req) {
36
- const user = req['user'];
37
- const { room = 'test', permission = 'read' } = body;
38
- return await this.roomsService.getRoomToken({
39
- spaceId: user.space,
40
- userId: user.user,
41
- roomId: room,
42
- readonly: permission === 'read',
47
+ getToken(body, req) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const user = req['user'];
50
+ const { room = 'test', permission = 'read' } = body;
51
+ return yield this.roomsService.getRoomToken({
52
+ spaceId: user.space,
53
+ userId: user.user,
54
+ roomId: room,
55
+ readonly: permission === 'read',
56
+ });
43
57
  });
44
58
  }
45
- async getUsers(userIds) {
46
- const users = await this.roomsService.getUsers(userIds);
47
- return users;
48
- }
49
- async searchUsers(req, keyword, roomdId) {
50
- const spaceId = req['jwt'].sid;
51
- const users = await this.roomsService.searchUsers(spaceId, keyword, roomdId);
52
- return users;
53
- }
54
- async getRooms(roomIds) {
55
- const rooms = await this.roomsService.getRooms(roomIds);
56
- return rooms;
57
- }
58
- async getThreads(req, roomId) {
59
- const threads = await this.roomsService.getThreads(roomId);
60
- const inboxNotifications = await this.notificationsService.findNotifications({
61
- userId: req['jwt'].uid,
62
- roomId,
59
+ getUsers(userIds) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ if (typeof userIds === 'string') {
62
+ userIds = [userIds];
63
+ }
64
+ const users = yield this.roomsService.resolveUsers({ userIds });
65
+ return users;
63
66
  });
64
- return {
65
- data: threads,
66
- inboxNotifications: inboxNotifications.map((inboxNotification) => (0, lodash_1.omit)(inboxNotification, ['userId', '_id'])),
67
- meta: {
68
- nextCursor: null,
69
- requestedAt: new Date().toISOString(),
70
- permissionHints: {
71
- [roomId]: ['room:write'],
72
- },
73
- },
74
- deletedThreads: [],
75
- deletedInboxNotifications: [],
76
- };
77
67
  }
78
- async getThreadsDelta(req, roomId, since) {
79
- const sinceDate = new Date(since);
80
- const threads = await this.roomsService.getThreads(roomId, sinceDate);
81
- const inboxNotifications = await this.notificationsService.findNotifications({
82
- userId: req['jwt'].uid,
83
- roomId,
84
- sinceDate,
68
+ searchUsers(req, keyword, roomdId) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const spaceId = req['jwt'].sid;
71
+ const users = yield this.roomsService.searchUsers(spaceId, keyword, roomdId);
72
+ return users;
85
73
  });
86
- return {
87
- data: threads,
88
- inboxNotifications: inboxNotifications.map((inboxNotification) => (0, lodash_1.omit)(inboxNotification, ['userId', '_id'])),
89
- meta: {
90
- nextCursor: null,
91
- requestedAt: new Date().toISOString(),
92
- permissionHints: {
93
- [roomId]: ['room:write'],
94
- },
95
- },
96
- deletedThreads: [],
97
- deletedInboxNotifications: [],
98
- };
99
74
  }
100
- async createThread(req, roomId, record) {
101
- const userId = req['jwt'].uid;
102
- const newThread = await this.roomsService.createThread({
103
- id: record.id,
104
- comment: record.comment,
105
- roomId,
106
- userId,
107
- metadata: {},
108
- resolved: false,
75
+ getRooms(roomIds) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ if (typeof roomIds === 'string') {
78
+ roomIds = [roomIds];
79
+ }
80
+ const rooms = yield this.roomsService.resolveRoomInfo({ roomIds });
81
+ return rooms;
109
82
  });
110
- this.roomsGateway.broadcastToRoom(roomId, {
111
- type: ServerMsg_1.ServerMsgCode.THREAD_CREATED,
112
- threadId: record.id,
113
- });
114
- this.roomsGateway.broadcastToRoom(roomId, {
115
- type: ServerMsg_1.ServerMsgCode.COMMENT_CREATED,
116
- threadId: record.id,
117
- commentId: record.comment.id,
118
- });
119
- return newThread;
120
83
  }
121
- async threadWithNotification(req, roomId, threadId) {
122
- const thread = await this.roomsService.getThread(roomId, threadId);
123
- const inboxNotifications = await this.notificationsService.findNotifications({
124
- userId: req['jwt'].uid,
125
- roomId,
126
- threadId,
84
+ getThreads(req, roomId) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const threads = yield this.roomsService.getThreads(roomId);
87
+ const inboxNotifications = yield this.notificationsService.findNotifications({
88
+ userId: req['jwt'].uid,
89
+ roomId,
90
+ });
91
+ return {
92
+ data: threads,
93
+ inboxNotifications: inboxNotifications.map((inboxNotification) => (0, lodash_1.omit)(inboxNotification, ['userId', '_id'])),
94
+ meta: {
95
+ nextCursor: null,
96
+ requestedAt: new Date().toISOString(),
97
+ permissionHints: {
98
+ [roomId]: ['room:write'],
99
+ },
100
+ },
101
+ deletedThreads: [],
102
+ deletedInboxNotifications: [],
103
+ };
127
104
  });
128
- return {
129
- thread,
130
- inboxNotification: inboxNotifications[0]
131
- ? (0, lodash_1.omit)(inboxNotifications[0], ['userId', '_id'])
132
- : undefined,
133
- };
134
105
  }
135
- async threadMarkasResolved(req, roomId, threadId) {
136
- const newThread = await this.roomsService.updateThread(threadId, {
137
- resolved: true,
138
- });
139
- this.roomsGateway.broadcastToRoom(roomId, {
140
- type: ServerMsg_1.ServerMsgCode.THREAD_UPDATED,
141
- threadId: threadId,
106
+ getThreadsDelta(req, roomId, since) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const sinceDate = new Date(since);
109
+ const threads = yield this.roomsService.getThreads(roomId, sinceDate);
110
+ const inboxNotifications = yield this.notificationsService.findNotifications({
111
+ userId: req['jwt'].uid,
112
+ roomId,
113
+ sinceDate,
114
+ });
115
+ return {
116
+ data: threads,
117
+ inboxNotifications: inboxNotifications.map((inboxNotification) => (0, lodash_1.omit)(inboxNotification, ['userId', '_id'])),
118
+ meta: {
119
+ nextCursor: null,
120
+ requestedAt: new Date().toISOString(),
121
+ permissionHints: {
122
+ [roomId]: ['room:write'],
123
+ },
124
+ },
125
+ deletedThreads: [],
126
+ deletedInboxNotifications: [],
127
+ };
142
128
  });
143
- return newThread;
144
129
  }
145
- async threadMarkasUnResolved(req, roomId, threadId) {
146
- const newThread = await this.roomsService.updateThread(threadId, {
147
- resolved: false,
130
+ createThread(req, roomId, record) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ const userId = req['jwt'].uid;
133
+ const newThread = yield this.roomsService.createThread({
134
+ id: record.id,
135
+ comment: record.comment,
136
+ roomId,
137
+ userId,
138
+ metadata: {},
139
+ resolved: false,
140
+ });
141
+ this.roomsGateway.broadcastToRoom(roomId, {
142
+ type: ServerMsg_1.ServerMsgCode.THREAD_CREATED,
143
+ threadId: record.id,
144
+ });
145
+ this.roomsGateway.broadcastToRoom(roomId, {
146
+ type: ServerMsg_1.ServerMsgCode.COMMENT_CREATED,
147
+ threadId: record.id,
148
+ commentId: record.comment.id,
149
+ });
150
+ return newThread;
148
151
  });
149
- this.roomsGateway.broadcastToRoom(roomId, {
150
- type: ServerMsg_1.ServerMsgCode.THREAD_UPDATED,
151
- threadId: threadId,
152
+ }
153
+ threadWithNotification(req, roomId, threadId) {
154
+ return __awaiter(this, void 0, void 0, function* () {
155
+ const thread = yield this.roomsService.getThread({ roomId, threadId });
156
+ const inboxNotifications = yield this.notificationsService.findNotifications({
157
+ userId: req['jwt'].uid,
158
+ roomId,
159
+ threadId,
160
+ });
161
+ return {
162
+ thread,
163
+ inboxNotification: inboxNotifications[0]
164
+ ? (0, lodash_1.omit)(inboxNotifications[0], ['userId', '_id'])
165
+ : undefined,
166
+ };
152
167
  });
153
- return newThread;
154
168
  }
155
- async createComment(req, roomId, threadId, record) {
156
- const userId = req['jwt'].uid;
157
- const newComment = await this.roomsService.createComment({
158
- id: record.id,
159
- attachmentIds: record.attachmentIds,
160
- body: record.body,
161
- roomId,
162
- threadId: threadId,
163
- userId: userId,
169
+ threadMarkasResolved(req, roomId, threadId) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ const newThread = yield this.roomsService.updateThread(threadId, {
172
+ resolved: true,
173
+ });
174
+ this.roomsGateway.broadcastToRoom(roomId, {
175
+ type: ServerMsg_1.ServerMsgCode.THREAD_UPDATED,
176
+ threadId: threadId,
177
+ });
178
+ return newThread;
164
179
  });
165
- await this.roomsService.updateThread(threadId);
166
- this.roomsGateway.broadcastToRoom(roomId, {
167
- type: ServerMsg_1.ServerMsgCode.COMMENT_CREATED,
168
- threadId: threadId,
169
- commentId: record.id,
180
+ }
181
+ threadMarkasUnResolved(req, roomId, threadId) {
182
+ return __awaiter(this, void 0, void 0, function* () {
183
+ const newThread = yield this.roomsService.updateThread(threadId, {
184
+ resolved: false,
185
+ });
186
+ this.roomsGateway.broadcastToRoom(roomId, {
187
+ type: ServerMsg_1.ServerMsgCode.THREAD_UPDATED,
188
+ threadId: threadId,
189
+ });
190
+ return newThread;
170
191
  });
171
- return newComment;
172
192
  }
173
- async updateComment(req, roomId, threadId, commentId, record) {
174
- const userId = req['jwt'].uid;
175
- const newComment = await this.roomsService.updateComment(commentId, {
176
- attachmentIds: record.attachmentIds,
177
- body: record.body,
178
- userId,
193
+ createComment(req, roomId, threadId, record) {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ const userId = req['jwt'].uid;
196
+ const newComment = yield this.roomsService.createComment({
197
+ id: record.id,
198
+ attachmentIds: record.attachmentIds,
199
+ body: record.body,
200
+ roomId,
201
+ threadId: threadId,
202
+ userId: userId,
203
+ });
204
+ yield this.roomsService.updateThread(threadId);
205
+ this.roomsGateway.broadcastToRoom(roomId, {
206
+ type: ServerMsg_1.ServerMsgCode.COMMENT_CREATED,
207
+ threadId: threadId,
208
+ commentId: record.id,
209
+ });
210
+ return newComment;
179
211
  });
180
- await this.roomsService.updateThread(threadId);
181
- this.roomsGateway.broadcastToRoom(roomId, {
182
- type: ServerMsg_1.ServerMsgCode.COMMENT_EDITED,
183
- threadId: threadId,
184
- commentId: commentId,
212
+ }
213
+ updateComment(req, roomId, threadId, commentId, record) {
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ const userId = req['jwt'].uid;
216
+ const newComment = yield this.roomsService.updateComment(commentId, {
217
+ attachmentIds: record.attachmentIds,
218
+ body: record.body,
219
+ userId,
220
+ });
221
+ yield this.roomsService.updateThread(threadId);
222
+ this.roomsGateway.broadcastToRoom(roomId, {
223
+ type: ServerMsg_1.ServerMsgCode.COMMENT_EDITED,
224
+ threadId: threadId,
225
+ commentId: commentId,
226
+ });
227
+ return newComment;
185
228
  });
186
- return newComment;
187
229
  }
188
- async deleteComment(req, roomId, threadId, commentId) {
189
- await this.roomsService.deleteComment(commentId);
190
- await this.roomsService.updateThread(threadId);
191
- this.roomsGateway.broadcastToRoom(roomId, {
192
- type: ServerMsg_1.ServerMsgCode.COMMENT_DELETED,
193
- threadId: threadId,
194
- commentId: commentId,
230
+ deleteComment(req, roomId, threadId, commentId) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ yield this.roomsService.deleteComment(commentId);
233
+ yield this.roomsService.updateThread(threadId);
234
+ this.roomsGateway.broadcastToRoom(roomId, {
235
+ type: ServerMsg_1.ServerMsgCode.COMMENT_DELETED,
236
+ threadId: threadId,
237
+ commentId: commentId,
238
+ });
239
+ return {};
195
240
  });
196
- return {};
197
241
  }
198
- async getInboxNotificationsSince(req, since) {
199
- const userId = req['jwt'].uid;
200
- const sinceDate = new Date(since);
201
- const requestedAt = new Date();
202
- const notifications = await this.notificationsService.findNotifications({
203
- userId,
204
- sinceDate,
242
+ getInboxNotificationsSince(req, since) {
243
+ return __awaiter(this, void 0, void 0, function* () {
244
+ const userId = req['jwt'].uid;
245
+ const sinceDate = new Date(since);
246
+ const requestedAt = new Date();
247
+ const notifications = yield this.notificationsService.findNotifications({
248
+ userId,
249
+ sinceDate,
250
+ });
251
+ const threads = yield this.roomsService.getThreadsByIds((0, lodash_1.uniqBy)(notifications, (notification) => `${notification.roomId}-${notification.threadId}`));
252
+ return {
253
+ inboxNotifications: notifications.map((notification) => (0, lodash_1.omit)(notification, ['userId', '_id'])),
254
+ threads,
255
+ meta: { requestedAt },
256
+ deletedThreads: [],
257
+ deletedInboxNotifications: [],
258
+ };
205
259
  });
206
- const threads = await this.roomsService.getThreadsByIds((0, lodash_1.uniqBy)(notifications, (notification) => `${notification.roomId}-${notification.threadId}`));
207
- return {
208
- inboxNotifications: notifications.map((notification) => (0, lodash_1.omit)(notification, ['userId', '_id'])),
209
- threads,
210
- meta: { requestedAt },
211
- deletedThreads: [],
212
- deletedInboxNotifications: [],
213
- };
214
260
  }
215
- async getInboxNotifications(req, unread, limit) {
216
- const userId = req['jwt'].uid;
217
- const requestedAt = new Date();
218
- const notifications = await this.notificationsService.findNotifications({
219
- userId,
220
- unread: unread === 'true',
221
- limit: Number(limit),
261
+ getInboxNotifications(req, unread, limit) {
262
+ return __awaiter(this, void 0, void 0, function* () {
263
+ const userId = req['jwt'].uid;
264
+ const requestedAt = new Date();
265
+ const notifications = yield this.notificationsService.findNotifications({
266
+ userId,
267
+ unread: unread === 'true',
268
+ limit: Number(limit),
269
+ });
270
+ const threads = yield this.roomsService.getThreadsByIds((0, lodash_1.uniqBy)(notifications, (notification) => `${notification.roomId}-${notification.threadId}`));
271
+ return {
272
+ inboxNotifications: notifications.map((notification) => (0, lodash_1.omit)(notification, ['userId', '_id'])),
273
+ threads,
274
+ meta: {
275
+ nextCursor: null,
276
+ requestedAt,
277
+ },
278
+ deletedThreads: [],
279
+ deletedInboxNotifications: [],
280
+ };
222
281
  });
223
- const threads = await this.roomsService.getThreadsByIds((0, lodash_1.uniqBy)(notifications, (notification) => `${notification.roomId}-${notification.threadId}`));
224
- return {
225
- inboxNotifications: notifications.map((notification) => (0, lodash_1.omit)(notification, ['userId', '_id'])),
226
- threads,
227
- meta: {
228
- nextCursor: null,
229
- requestedAt,
230
- },
231
- deletedThreads: [],
232
- deletedInboxNotifications: [],
233
- };
234
282
  }
235
- async read(req, inboxNotificationIds) {
236
- const userId = req['jwt'].uid;
237
- const notifications = await this.notificationsService.markAsRead({
238
- userId,
239
- inboxNotificationIds,
283
+ read(req, inboxNotificationIds) {
284
+ return __awaiter(this, void 0, void 0, function* () {
285
+ const userId = req['jwt'].uid;
286
+ const notifications = yield this.notificationsService.markAsRead({
287
+ userId,
288
+ inboxNotificationIds,
289
+ });
290
+ return {
291
+ data: (notifications === null || notifications === void 0 ? void 0 : notifications.length) > 0
292
+ ? notifications.map((notification) => (0, lodash_1.omit)(notification, ['userId', '_id']))
293
+ : undefined,
294
+ };
240
295
  });
241
- return {
242
- data: notifications?.length > 0
243
- ? notifications.map((notification) => (0, lodash_1.omit)(notification, ['userId', '_id']))
244
- : undefined,
245
- };
246
296
  }
247
- async roomRead(req, roomId, inboxNotificationIds) {
248
- const userId = req['jwt'].uid;
249
- const notifications = await this.notificationsService.markAsRead({
250
- roomId,
251
- userId,
252
- inboxNotificationIds,
297
+ roomRead(req, roomId, inboxNotificationIds) {
298
+ return __awaiter(this, void 0, void 0, function* () {
299
+ const userId = req['jwt'].uid;
300
+ const notifications = yield this.notificationsService.markAsRead({
301
+ roomId,
302
+ userId,
303
+ inboxNotificationIds,
304
+ });
305
+ return {
306
+ data: (notifications === null || notifications === void 0 ? void 0 : notifications.length) > 0
307
+ ? notifications.map((notification) => (0, lodash_1.omit)(notification, ['userId', '_id']))
308
+ : undefined,
309
+ };
253
310
  });
254
- return {
255
- data: notifications?.length > 0
256
- ? notifications.map((notification) => (0, lodash_1.omit)(notification, ['userId', '_id']))
257
- : undefined,
258
- };
259
311
  }
260
- async presignedUrls(attachmentIds) {
261
- const urls = await Promise.all(attachmentIds.map(async (attachmentId) => {
262
- return this.filesService.getPreSignedUrl('cfs.files.filerecord', attachmentId);
263
- }));
264
- return { urls };
312
+ presignedUrls(attachmentIds) {
313
+ return __awaiter(this, void 0, void 0, function* () {
314
+ const urls = yield Promise.all(attachmentIds.map((attachmentId) => __awaiter(this, void 0, void 0, function* () {
315
+ return this.filesService.getPreSignedUrl('cfs.files.filerecord', attachmentId);
316
+ })));
317
+ return { urls };
318
+ });
265
319
  }
266
- async uploadFile(roomId, attachmentId, fileName, fileSize, req) {
267
- if (req.headers['content-type'] !== 'application/octet-stream') {
268
- throw new common_1.HttpException('Invalid content type', common_1.HttpStatus.BAD_REQUEST);
269
- }
270
- const fileBuffer = await rawBody(req);
271
- const file = {
272
- buffer: fileBuffer,
273
- originalname: fileName,
274
- size: fileSize,
275
- };
276
- const metadata = {
277
- _id: attachmentId,
278
- objectName: 'b6_rooms',
279
- recordId: roomId,
280
- };
281
- if (!file) {
282
- throw new Error('未找到上传的文件');
283
- }
284
- const fileRecord = await this.filesService.uploadFile('cfs.files.filerecord', file, metadata);
285
- return fileRecord;
320
+ uploadFile(roomId, attachmentId, fileName, fileSize, req) {
321
+ return __awaiter(this, void 0, void 0, function* () {
322
+ if (req.headers['content-type'] !== 'application/octet-stream') {
323
+ throw new common_1.HttpException('Invalid content type', common_1.HttpStatus.BAD_REQUEST);
324
+ }
325
+ const fileBuffer = yield rawBody(req);
326
+ const file = {
327
+ buffer: fileBuffer,
328
+ originalname: fileName,
329
+ size: fileSize,
330
+ };
331
+ const metadata = {
332
+ _id: attachmentId,
333
+ objectName: 'b6_rooms',
334
+ recordId: roomId,
335
+ };
336
+ if (!file) {
337
+ throw new Error('未找到上传的文件');
338
+ }
339
+ const fileRecord = yield this.filesService.uploadFile('cfs.files.filerecord', file, metadata);
340
+ return fileRecord;
341
+ });
286
342
  }
287
- async createReaction(req, roomId, threadId, commentId, emoji) {
288
- const userId = req['jwt'].uid;
289
- const newComment = await this.roomsService.createReaction(commentId, {
290
- userId: userId,
291
- emoji: emoji,
343
+ createReaction(req, roomId, threadId, commentId, emoji) {
344
+ return __awaiter(this, void 0, void 0, function* () {
345
+ const userId = req['jwt'].uid;
346
+ const newComment = yield this.roomsService.createReaction(commentId, {
347
+ userId: userId,
348
+ emoji: emoji,
349
+ });
350
+ yield this.roomsService.updateThread(threadId);
351
+ this.roomsGateway.broadcastToRoom(roomId, {
352
+ type: ServerMsg_1.ServerMsgCode.COMMENT_REACTION_ADDED,
353
+ threadId: threadId,
354
+ commentId: commentId,
355
+ emoji: emoji,
356
+ });
357
+ return newComment;
292
358
  });
293
- await this.roomsService.updateThread(threadId);
294
- this.roomsGateway.broadcastToRoom(roomId, {
295
- type: ServerMsg_1.ServerMsgCode.COMMENT_REACTION_ADDED,
296
- threadId: threadId,
297
- commentId: commentId,
298
- emoji: emoji,
359
+ }
360
+ deleteReaction(req, roomId, threadId, commentId, emoji) {
361
+ return __awaiter(this, void 0, void 0, function* () {
362
+ const userId = req['jwt'].uid;
363
+ yield this.roomsService.deleteReaction(commentId, { emoji, userId });
364
+ yield this.roomsService.updateThread(threadId);
365
+ this.roomsGateway.broadcastToRoom(roomId, {
366
+ type: ServerMsg_1.ServerMsgCode.COMMENT_REACTION_REMOVED,
367
+ threadId: threadId,
368
+ commentId: commentId,
369
+ emoji: emoji,
370
+ });
371
+ return {};
299
372
  });
300
- return newComment;
301
373
  }
302
- async deleteReaction(req, roomId, threadId, commentId, emoji) {
303
- const userId = req['jwt'].uid;
304
- await this.roomsService.deleteReaction(commentId, { emoji, userId });
305
- await this.roomsService.updateThread(threadId);
306
- this.roomsGateway.broadcastToRoom(roomId, {
307
- type: ServerMsg_1.ServerMsgCode.COMMENT_REACTION_REMOVED,
308
- threadId: threadId,
309
- commentId: commentId,
310
- emoji: emoji,
374
+ sendEmail(body) {
375
+ return __awaiter(this, void 0, void 0, function* () {
376
+ this.emailNotificationService.sendThreadNotificationEmail(body);
311
377
  });
312
- return {};
313
378
  }
314
379
  };
315
380
  __decorate([
@@ -522,13 +587,26 @@ __decorate([
522
587
  __metadata("design:paramtypes", [Object, String, String, String, String]),
523
588
  __metadata("design:returntype", Promise)
524
589
  ], RoomsController.prototype, "deleteReaction", null);
590
+ __decorate([
591
+ (0, common_1.Post)('email'),
592
+ (0, swagger_1.ApiBody)({
593
+ schema: {
594
+ type: 'object',
595
+ },
596
+ }),
597
+ __param(0, (0, common_1.Body)()),
598
+ __metadata("design:type", Function),
599
+ __metadata("design:paramtypes", [Object]),
600
+ __metadata("design:returntype", Promise)
601
+ ], RoomsController.prototype, "sendEmail", null);
525
602
  RoomsController = __decorate([
526
603
  (0, common_1.Controller)('v2/c/'),
527
604
  __metadata("design:paramtypes", [rooms_service_1.RoomsService,
528
605
  files_1.FilesService,
529
606
  jwt_1.JwtService,
530
607
  rooms_gateway_1.RoomsGateway,
531
- notifications_service_1.NotificationsService])
608
+ notifications_service_1.NotificationsService,
609
+ emailNotification_service_1.EmailNotificationService])
532
610
  ], RoomsController);
533
611
  exports.RoomsController = RoomsController;
534
612
  //# sourceMappingURL=rooms.controller.js.map