@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.
- package/dist/emails/UnreadMention.d.ts +9 -0
- package/dist/emails/UnreadMention.js +54 -0
- package/dist/emails/UnreadMention.js.map +1 -0
- package/dist/emails/UnreadReplies.d.ts +9 -0
- package/dist/emails/UnreadReplies.js +68 -0
- package/dist/emails/UnreadReplies.js.map +1 -0
- package/dist/emails/_components/comment.d.ts +1 -0
- package/dist/emails/_components/comment.js +32 -0
- package/dist/emails/_components/comment.js.map +1 -0
- package/dist/emails/_components/header.d.ts +2 -0
- package/dist/emails/_components/header.js +15 -0
- package/dist/emails/_components/header.js.map +1 -0
- package/dist/emails/_components/headline.d.ts +5 -0
- package/dist/emails/_components/headline.js +17 -0
- package/dist/emails/_components/headline.js.map +1 -0
- package/dist/emails/_components/layout.d.ts +5 -0
- package/dist/emails/_components/layout.js +24 -0
- package/dist/emails/_components/layout.js.map +1 -0
- package/dist/emails/_lib/types.d.ts +9 -0
- package/dist/emails/_lib/types.js +3 -0
- package/dist/emails/_lib/types.js.map +1 -0
- package/dist/emails/_styles/colors.d.ts +2 -0
- package/dist/emails/_styles/colors.js +7 -0
- package/dist/emails/_styles/colors.js.map +1 -0
- package/dist/emails/_utils/cn.d.ts +2 -0
- package/dist/emails/_utils/cn.js +10 -0
- package/dist/emails/_utils/cn.js.map +1 -0
- package/dist/emails/_utils/comments.d.ts +7 -0
- package/dist/emails/_utils/comments.js +29 -0
- package/dist/emails/_utils/comments.js.map +1 -0
- package/dist/emails/_utils/getProps.d.ts +1 -0
- package/dist/emails/_utils/getProps.js +11 -0
- package/dist/emails/_utils/getProps.js.map +1 -0
- package/dist/rooms/app.controller.d.ts +3 -1
- package/dist/rooms/app.controller.js +61 -46
- package/dist/rooms/app.controller.js.map +1 -1
- package/dist/rooms/emailNotification.service.d.ts +17 -0
- package/dist/rooms/emailNotification.service.js +113 -0
- package/dist/rooms/emailNotification.service.js.map +1 -0
- package/dist/rooms/emails/comment-body.d.ts +44 -0
- package/dist/rooms/emails/comment-body.js +138 -0
- package/dist/rooms/emails/comment-body.js.map +1 -0
- package/dist/rooms/emails/comment-with-body.d.ts +6 -0
- package/dist/rooms/emails/comment-with-body.js +17 -0
- package/dist/rooms/emails/comment-with-body.js.map +1 -0
- package/dist/rooms/emails/index.d.ts +4 -0
- package/dist/rooms/emails/index.js +7 -0
- package/dist/rooms/emails/index.js.map +1 -0
- package/dist/rooms/emails/lib/batch-users-resolver.d.ts +9 -0
- package/dist/rooms/emails/lib/batch-users-resolver.js +67 -0
- package/dist/rooms/emails/lib/batch-users-resolver.js.map +1 -0
- package/dist/rooms/emails/lib/css-properties.d.ts +3 -0
- package/dist/rooms/emails/lib/css-properties.js +96 -0
- package/dist/rooms/emails/lib/css-properties.js.map +1 -0
- package/dist/rooms/emails/lib/warning.d.ts +1 -0
- package/dist/rooms/emails/lib/warning.js +20 -0
- package/dist/rooms/emails/lib/warning.js.map +1 -0
- package/dist/rooms/emails/thread-notification.d.ts +90 -0
- package/dist/rooms/emails/thread-notification.js +297 -0
- package/dist/rooms/emails/thread-notification.js.map +1 -0
- package/dist/rooms/globals/augmentation.d.ts +0 -5
- package/dist/rooms/lib/utils.js +21 -10
- package/dist/rooms/lib/utils.js.map +1 -1
- package/dist/rooms/liveblocks.service.d.ts +16 -0
- package/dist/rooms/liveblocks.service.js +54 -0
- package/dist/rooms/liveblocks.service.js.map +1 -0
- package/dist/rooms/notifications.service.d.ts +4 -0
- package/dist/rooms/notifications.service.js +107 -80
- package/dist/rooms/notifications.service.js.map +1 -1
- package/dist/rooms/rooms.controller.d.ts +5 -3
- package/dist/rooms/rooms.controller.js +321 -243
- package/dist/rooms/rooms.controller.js.map +1 -1
- package/dist/rooms/rooms.gateway.js +132 -109
- package/dist/rooms/rooms.gateway.js.map +1 -1
- package/dist/rooms/rooms.guard.js +31 -19
- package/dist/rooms/rooms.guard.js.map +1 -1
- package/dist/rooms/rooms.module.js +10 -1
- package/dist/rooms/rooms.module.js.map +1 -1
- package/dist/rooms/rooms.moleculer.js +85 -66
- package/dist/rooms/rooms.moleculer.js.map +1 -1
- package/dist/rooms/rooms.service.d.ts +17 -4
- package/dist/rooms/rooms.service.js +408 -340
- package/dist/rooms/rooms.service.js.map +1 -1
- package/package.json +18 -7
- package/src/emails/UnreadMention.tsx +76 -0
- package/src/emails/UnreadReplies.tsx +106 -0
- package/src/emails/_components/comment.tsx +70 -0
- package/src/emails/_components/header.tsx +27 -0
- package/src/emails/_components/headline.tsx +20 -0
- package/src/emails/_components/layout.tsx +45 -0
- package/src/emails/_lib/types.ts +10 -0
- package/src/emails/_styles/colors.ts +7 -0
- package/src/emails/_utils/cn.ts +6 -0
- package/src/emails/_utils/comments.ts +61 -0
- package/src/emails/_utils/getProps.ts +7 -0
- package/src/rooms/app.controller.ts +7 -2
- package/src/rooms/emailNotification.service.tsx +152 -0
- package/src/rooms/emails/comment-body.tsx +342 -0
- package/src/rooms/emails/comment-with-body.ts +24 -0
- package/src/rooms/emails/index.ts +25 -0
- package/src/rooms/emails/lib/batch-users-resolver.ts +120 -0
- package/src/rooms/emails/lib/css-properties.ts +123 -0
- package/src/rooms/emails/lib/warning.ts +25 -0
- package/src/rooms/emails/thread-notification.tsx +583 -0
- package/src/rooms/globals/augmentation.ts +8 -8
- package/src/rooms/liveblocks.service.ts +25 -0
- package/src/rooms/notifications.service.ts +22 -10
- package/src/rooms/rooms.controller.ts +22 -4
- package/src/rooms/rooms.module.ts +10 -1
- package/src/rooms/rooms.service.ts +35 -20
- package/tsconfig.json +2 -0
- 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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|