@builder6/rooms 0.9.3 → 0.10.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/README.md +1 -0
- package/dist/rooms/app.controller.d.ts +10 -0
- package/dist/rooms/app.controller.js +72 -0
- package/dist/rooms/app.controller.js.map +1 -0
- package/dist/rooms/dtos/notifications.dto.d.ts +9 -0
- package/dist/rooms/dtos/notifications.dto.js +7 -0
- package/dist/rooms/dtos/notifications.dto.js.map +1 -0
- package/dist/rooms/dtos/room_members.dto.d.ts +7 -0
- package/dist/rooms/dtos/room_members.dto.js +53 -0
- package/dist/rooms/dtos/room_members.dto.js.map +1 -0
- package/dist/rooms/dtos/rooms.dto.d.ts +12 -0
- package/dist/rooms/dtos/rooms.dto.js +59 -0
- package/dist/rooms/dtos/rooms.dto.js.map +1 -0
- package/dist/rooms/notifications.service.d.ts +19 -0
- package/dist/rooms/notifications.service.js +68 -0
- package/dist/rooms/notifications.service.js.map +1 -0
- package/dist/rooms/rooms.controller.d.ts +31 -6
- package/dist/rooms/rooms.controller.js +119 -24
- package/dist/rooms/rooms.controller.js.map +1 -1
- package/dist/rooms/rooms.gateway.d.ts +3 -1
- package/dist/rooms/rooms.gateway.js +12 -5
- package/dist/rooms/rooms.gateway.js.map +1 -1
- package/dist/rooms/rooms.guard.d.ts +1 -3
- package/dist/rooms/rooms.guard.js +2 -5
- package/dist/rooms/rooms.guard.js.map +1 -1
- package/dist/rooms/rooms.module.js +7 -2
- package/dist/rooms/rooms.module.js.map +1 -1
- package/dist/rooms/rooms.moleculer.d.ts +11 -0
- package/dist/rooms/rooms.moleculer.js +91 -0
- package/dist/rooms/rooms.moleculer.js.map +1 -0
- package/dist/rooms/rooms.service.d.ts +35 -4
- package/dist/rooms/rooms.service.js +144 -8
- package/dist/rooms/rooms.service.js.map +1 -1
- package/package.json +12 -3
- package/src/rooms/app.controller.ts +63 -0
- package/src/rooms/dtos/notifications.dto.ts +9 -0
- package/src/rooms/dtos/room_members.dto.ts +31 -0
- package/src/rooms/dtos/rooms.dto.ts +51 -0
- package/src/rooms/notifications.service.ts +85 -0
- package/src/rooms/rooms.controller.ts +132 -16
- package/src/rooms/rooms.gateway.ts +17 -4
- package/src/rooms/rooms.guard.ts +1 -1
- package/src/rooms/rooms.module.ts +7 -2
- package/src/rooms/rooms.moleculer.ts +78 -0
- package/src/rooms/rooms.service.ts +208 -6
- package/.eslintrc.js +0 -25
package/README.md
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Response } from 'express';
|
|
2
|
+
import { PagesService } from '@builder6/pages';
|
|
3
|
+
export declare class RoomsAppController {
|
|
4
|
+
private readonly pagesService;
|
|
5
|
+
constructor(pagesService: PagesService);
|
|
6
|
+
getRooms(roomId: string, query: Record<string, any>, req: Request, res: Response): Promise<{
|
|
7
|
+
error: string;
|
|
8
|
+
details: any;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RoomsAppController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@builder6/core");
|
|
18
|
+
const pages_1 = require("@builder6/pages");
|
|
19
|
+
let RoomsAppController = class RoomsAppController {
|
|
20
|
+
constructor(pagesService) {
|
|
21
|
+
this.pagesService = pagesService;
|
|
22
|
+
}
|
|
23
|
+
async getRooms(roomId = 'test', query, req, res) {
|
|
24
|
+
const user = req['user'];
|
|
25
|
+
try {
|
|
26
|
+
const schema = {
|
|
27
|
+
type: 'rooms-provider',
|
|
28
|
+
baseUrl: '',
|
|
29
|
+
body: [
|
|
30
|
+
{
|
|
31
|
+
type: 'rooms-inbox-popover',
|
|
32
|
+
className: 'flex flex-col m-3 gap-3',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'rooms-comments',
|
|
36
|
+
className: 'flex flex-col m-3 gap-3',
|
|
37
|
+
roomId: `${roomId}`,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
const data = {};
|
|
42
|
+
const env = {
|
|
43
|
+
assetUrls: [
|
|
44
|
+
'https://unpkg.com/@steedos-widgets/liveblocks@6.3.12-beta.1/dist/assets.json',
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
const rendered = await this.pagesService.renderAmis(schema, data, env, user);
|
|
48
|
+
res.status(200).send(rendered);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.log(error);
|
|
52
|
+
return { error: 'Rooms rendering failed', details: error.message };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, common_1.Get)(':roomId'),
|
|
58
|
+
__param(0, (0, common_1.Param)('roomId')),
|
|
59
|
+
__param(1, (0, common_1.Query)()),
|
|
60
|
+
__param(2, (0, common_1.Req)()),
|
|
61
|
+
__param(3, (0, common_1.Res)()),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [String, Object, Request, Object]),
|
|
64
|
+
__metadata("design:returntype", Promise)
|
|
65
|
+
], RoomsAppController.prototype, "getRooms", null);
|
|
66
|
+
RoomsAppController = __decorate([
|
|
67
|
+
(0, common_1.Controller)('b6/rooms/'),
|
|
68
|
+
(0, common_1.UseGuards)(core_1.AuthGuard),
|
|
69
|
+
__metadata("design:paramtypes", [pages_1.PagesService])
|
|
70
|
+
], RoomsAppController);
|
|
71
|
+
exports.RoomsAppController = RoomsAppController;
|
|
72
|
+
//# sourceMappingURL=app.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../../src/rooms/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AAExB,yCAA2C;AAC3C,2CAA+C;AAKxC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAGrD,AAAN,KAAK,CAAC,QAAQ,CACK,SAAiB,MAAM,EAC/B,KAA0B,EAC5B,GAAY,EACZ,GAAa;QAEpB,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI;YACF,MAAM,MAAM,GAAG;gBACb,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,EAAE;gBACX,IAAI,EAAE;oBACJ;wBACE,IAAI,EAAE,qBAAqB;wBAC3B,SAAS,EAAE,yBAAyB;qBACrC;oBACD;wBACE,IAAI,EAAE,gBAAgB;wBACtB,SAAS,EAAE,yBAAyB;wBACpC,MAAM,EAAE,GAAG,MAAM,EAAE;qBACpB;iBACF;aACF,CAAC;YACF,MAAM,IAAI,GAAG,EAAE,CAAC;YAChB,MAAM,GAAG,GAAG;gBACV,SAAS,EAAE;oBACT,8EAA8E;iBAC/E;aACF,CAAC;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CACjD,MAAM,EACN,IAAI,EACJ,GAAG,EACH,IAAI,CACL,CAAC;YAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAChC;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,EAAE,KAAK,EAAE,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;SACpE;IACH,CAAC;CACF,CAAA;AA1CO;IADL,IAAA,YAAG,EAAC,SAAS,CAAC;IAEZ,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IACf,WAAA,IAAA,cAAK,GAAE,CAAA;IACP,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,YAAG,GAAE,CAAA;;qDADM,OAAO;;kDAsCpB;AA7CU,kBAAkB;IAF9B,IAAA,mBAAU,EAAC,WAAW,CAAC;IACvB,IAAA,kBAAS,EAAC,gBAAS,CAAC;qCAEwB,oBAAY;GAD5C,kBAAkB,CA8C9B;AA9CY,gDAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.dto.js","sourceRoot":"","sources":["../../../src/rooms/dtos/notifications.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;CAQ3B;AARD,0CAQC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
exports.RoomMemberDTO = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const rooms_dto_1 = require("./rooms.dto");
|
|
15
|
+
class RoomMemberDTO {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.roles = [];
|
|
18
|
+
this.notifications = ['replies', 'mentions'];
|
|
19
|
+
this.scopes = rooms_dto_1.FULL_ACCESS;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, swagger_1.ApiProperty)(),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], RoomMemberDTO.prototype, "_id", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, swagger_1.ApiProperty)(),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], RoomMemberDTO.prototype, "userId", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, swagger_1.ApiProperty)({
|
|
32
|
+
enum: ['owner'],
|
|
33
|
+
default: [],
|
|
34
|
+
}),
|
|
35
|
+
(0, swagger_1.ApiProperty)(),
|
|
36
|
+
__metadata("design:type", Array)
|
|
37
|
+
], RoomMemberDTO.prototype, "roles", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, swagger_1.ApiProperty)({
|
|
40
|
+
enum: ['all', 'replies', 'mentions'],
|
|
41
|
+
default: ['replies', 'mentions'],
|
|
42
|
+
}),
|
|
43
|
+
__metadata("design:type", Array)
|
|
44
|
+
], RoomMemberDTO.prototype, "notifications", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, swagger_1.ApiProperty)({
|
|
47
|
+
enum: ['room:read', 'room:write'],
|
|
48
|
+
default: rooms_dto_1.FULL_ACCESS,
|
|
49
|
+
}),
|
|
50
|
+
__metadata("design:type", Array)
|
|
51
|
+
], RoomMemberDTO.prototype, "scopes", void 0);
|
|
52
|
+
exports.RoomMemberDTO = RoomMemberDTO;
|
|
53
|
+
//# sourceMappingURL=room_members.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room_members.dto.js","sourceRoot":"","sources":["../../../src/rooms/dtos/room_members.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,2CAA0C;AAE1C,MAAa,aAAa;IAA1B;QAcE,UAAK,GAAc,EAAE,CAAC;QAMtB,kBAAa,GAAc,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAMnD,WAAM,GAAc,uBAAW,CAAC;IAClC,CAAC;CAAA;AA1BC;IAAC,IAAA,qBAAW,GAAE;;0CACD;AAEb;IAAC,IAAA,qBAAW,GAAE;;6CACC;AAGf;IAAC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,CAAC,OAAO,CAAC;QACf,OAAO,EAAE,EAAE;KACZ,CAAC;IAED,IAAA,qBAAW,GAAE;;4CACQ;AAEtB;IAAC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC;QACpC,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;KACjC,CAAC;;oDACiD;AAEnD;IAAC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;QACjC,OAAO,EAAE,uBAAW;KACrB,CAAC;;6CAC8B;AA1BlC,sCA2BC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RoomMemberDTO } from './room_members.dto';
|
|
2
|
+
export declare const READ_ACCESS: string[];
|
|
3
|
+
export declare const FULL_ACCESS: string[];
|
|
4
|
+
export declare class RoomDTO {
|
|
5
|
+
_id?: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
membershipType?: string;
|
|
9
|
+
members?: RoomMemberDTO[];
|
|
10
|
+
defaultScopes?: string[];
|
|
11
|
+
defaultNotifications?: string[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
exports.RoomDTO = exports.FULL_ACCESS = exports.READ_ACCESS = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
exports.READ_ACCESS = [
|
|
15
|
+
'room:read',
|
|
16
|
+
'room:presence:write',
|
|
17
|
+
'comments:read',
|
|
18
|
+
];
|
|
19
|
+
exports.FULL_ACCESS = ['room:write', 'comments:write'];
|
|
20
|
+
class RoomDTO {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.defaultScopes = exports.FULL_ACCESS;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, swagger_1.ApiProperty)(),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], RoomDTO.prototype, "_id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], RoomDTO.prototype, "name", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, swagger_1.ApiProperty)(),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], RoomDTO.prototype, "description", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, swagger_1.ApiProperty)({
|
|
39
|
+
enum: ['standard', 'private', 'shared'],
|
|
40
|
+
default: 'standard',
|
|
41
|
+
}),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], RoomDTO.prototype, "membershipType", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, swagger_1.ApiProperty)({
|
|
46
|
+
enum: ['room:read', 'room:write'],
|
|
47
|
+
default: exports.FULL_ACCESS,
|
|
48
|
+
}),
|
|
49
|
+
__metadata("design:type", Array)
|
|
50
|
+
], RoomDTO.prototype, "defaultScopes", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, swagger_1.ApiProperty)({
|
|
53
|
+
enum: ['all', 'replies', 'mentions'],
|
|
54
|
+
default: ['replies', 'mentions'],
|
|
55
|
+
}),
|
|
56
|
+
__metadata("design:type", Array)
|
|
57
|
+
], RoomDTO.prototype, "defaultNotifications", void 0);
|
|
58
|
+
exports.RoomDTO = RoomDTO;
|
|
59
|
+
//# sourceMappingURL=rooms.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rooms.dto.js","sourceRoot":"","sources":["../../../src/rooms/dtos/rooms.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAQjC,QAAA,WAAW,GAAG;IACzB,WAAW;IACX,qBAAqB;IACrB,eAAe;CAChB,CAAC;AAMW,QAAA,WAAW,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAE5D,MAAa,OAAO;IAApB;QAuBE,kBAAa,GAAc,mBAAW,CAAC;IAOzC,CAAC;CAAA;AA7BC;IAAC,IAAA,qBAAW,GAAE;;oCACD;AAEb;IAAC,IAAA,qBAAW,GAAE;;qCACD;AAEb;IAAC,IAAA,qBAAW,GAAE;;4CACO;AAGrB;IAAC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC;QACvC,OAAO,EAAE,UAAU;KACpB,CAAC;;+CACsB;AAIxB;IAAC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;QACjC,OAAO,EAAE,mBAAW;KACrB,CAAC;;8CACqC;AAEvC;IAAC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC;QACpC,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;KACjC,CAAC;;qDAC8B;AA7BlC,0BA8BC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MongodbService } from '@builder6/core';
|
|
2
|
+
import { ServiceBroker } from 'moleculer';
|
|
3
|
+
import { NotificationDTO } from './dtos/notifications.dto';
|
|
4
|
+
export declare class NotificationsService {
|
|
5
|
+
private mongodbService;
|
|
6
|
+
private readonly broker;
|
|
7
|
+
constructor(mongodbService: MongodbService, broker: ServiceBroker);
|
|
8
|
+
createThreadNotification({ id, userId, kind, notifiedAt, readAt, roomId, threadId, }: NotificationDTO): Promise<any>;
|
|
9
|
+
findNotifications({ userId, unread, limit, sinceDate, roomId, threadId, inboxNotificationIds, }: {
|
|
10
|
+
userId: string;
|
|
11
|
+
unread?: boolean;
|
|
12
|
+
limit?: number;
|
|
13
|
+
sinceDate?: Date;
|
|
14
|
+
roomId?: string;
|
|
15
|
+
threadId?: string;
|
|
16
|
+
inboxNotificationIds?: string[];
|
|
17
|
+
}): Promise<any>;
|
|
18
|
+
markAsRead(roomId: string, userId: string, notificationIds: string[]): Promise<any>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.NotificationsService = void 0;
|
|
16
|
+
const core_1 = require("@builder6/core");
|
|
17
|
+
const moleculer_1 = require("@builder6/moleculer");
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const moleculer_2 = require("moleculer");
|
|
20
|
+
let NotificationsService = class NotificationsService {
|
|
21
|
+
constructor(mongodbService, broker) {
|
|
22
|
+
this.mongodbService = mongodbService;
|
|
23
|
+
this.broker = broker;
|
|
24
|
+
}
|
|
25
|
+
async createThreadNotification({ id, userId, kind = 'thread', notifiedAt, readAt, roomId, threadId, }) {
|
|
26
|
+
return this.mongodbService.insertOne('b6_notifications', {
|
|
27
|
+
id,
|
|
28
|
+
userId,
|
|
29
|
+
kind,
|
|
30
|
+
notifiedAt,
|
|
31
|
+
readAt,
|
|
32
|
+
roomId,
|
|
33
|
+
threadId,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async findNotifications({ userId, unread, limit, sinceDate, roomId, threadId, inboxNotificationIds, }) {
|
|
37
|
+
const queryOptions = { userId };
|
|
38
|
+
if (unread)
|
|
39
|
+
queryOptions.readAt = null;
|
|
40
|
+
if (sinceDate) {
|
|
41
|
+
queryOptions.notifiedAt = { $gt: sinceDate };
|
|
42
|
+
}
|
|
43
|
+
if (roomId)
|
|
44
|
+
queryOptions.roomId = roomId;
|
|
45
|
+
if (threadId)
|
|
46
|
+
queryOptions.threadId = threadId;
|
|
47
|
+
if (inboxNotificationIds && inboxNotificationIds.length > 0) {
|
|
48
|
+
queryOptions.id = { $in: inboxNotificationIds };
|
|
49
|
+
}
|
|
50
|
+
const collection = (await this.mongodbService.getCollection('b6_notifications'));
|
|
51
|
+
const query = collection.find(queryOptions).sort({ notifiedAt: 1 });
|
|
52
|
+
if (limit)
|
|
53
|
+
query.limit(limit);
|
|
54
|
+
return query.toArray();
|
|
55
|
+
}
|
|
56
|
+
async markAsRead(roomId, userId, notificationIds) {
|
|
57
|
+
const collection = (await this.mongodbService.getCollection('b6_notifications'));
|
|
58
|
+
return collection.updateMany({ _id: { $in: notificationIds }, roomId, userId }, { $set: { readAt: new Date() } });
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
NotificationsService = __decorate([
|
|
62
|
+
(0, common_1.Injectable)(),
|
|
63
|
+
__param(1, (0, moleculer_1.InjectBroker)()),
|
|
64
|
+
__metadata("design:paramtypes", [core_1.MongodbService,
|
|
65
|
+
moleculer_2.ServiceBroker])
|
|
66
|
+
], NotificationsService);
|
|
67
|
+
exports.NotificationsService = NotificationsService;
|
|
68
|
+
//# sourceMappingURL=notifications.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.service.js","sourceRoot":"","sources":["../../src/rooms/notifications.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAgD;AAChD,mDAAmD;AACnD,2CAA4C;AAC5C,yCAA0C;AAInC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,YACU,cAA8B,EACL,MAAqB;QAD9C,mBAAc,GAAd,cAAc,CAAgB;QACL,WAAM,GAAN,MAAM,CAAe;IACrD,CAAC;IAEJ,KAAK,CAAC,wBAAwB,CAAC,EAC7B,EAAE,EACF,MAAM,EACN,IAAI,GAAG,QAAQ,EACf,UAAU,EACV,MAAM,EACN,MAAM,EACN,QAAQ,GACQ;QAChB,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,kBAAkB,EAAE;YACvD,EAAE;YACF,MAAM;YACN,IAAI;YACJ,UAAU;YACV,MAAM;YACN,MAAM;YACN,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,EACtB,MAAM,EACN,MAAM,EACN,KAAK,EACL,SAAS,EACT,MAAM,EACN,QAAQ,EACR,oBAAoB,GASrB;QACC,MAAM,YAAY,GAAG,EAAE,MAAM,EAO5B,CAAC;QACF,IAAI,MAAM;YAAE,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC;QACvC,IAAI,SAAS,EAAE;YACb,YAAY,CAAC,UAAU,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;SAC9C;QACD,IAAI,MAAM;YAAE,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC;QACzC,IAAI,QAAQ;YAAE,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC/C,IAAI,oBAAoB,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3D,YAAY,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAE,CAAC;SACjD;QACD,MAAM,UAAU,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CACzD,kBAAkB,CACnB,CAAQ,CAAC;QACV,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;QACpE,IAAI,KAAK;YAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAc,EAAE,MAAc,EAAE,eAAyB;QACxE,MAAM,UAAU,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CACzD,kBAAkB,CACnB,CAAQ,CAAC;QACV,OAAO,UAAU,CAAC,UAAU,CAC1B,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EACjD,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CACjC,CAAC;IACJ,CAAC;CACF,CAAA;AA7EY,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,wBAAY,GAAE,CAAA;qCADS,qBAAc;QACG,yBAAa;GAH7C,oBAAoB,CA6EhC;AA7EY,oDAAoB"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import { FilesService } from '@builder6/core';
|
|
1
2
|
import { RoomsService } from './rooms.service';
|
|
2
3
|
import { JwtService } from '@nestjs/jwt';
|
|
3
4
|
import { Request } from 'express';
|
|
4
|
-
import { FilesService } from '@builder6/core';
|
|
5
5
|
import { RoomsGateway } from './rooms.gateway';
|
|
6
|
+
import { NotificationsService } from './notifications.service';
|
|
6
7
|
export declare class RoomsController {
|
|
7
8
|
private roomsService;
|
|
8
9
|
private filesService;
|
|
9
10
|
private jwtService;
|
|
10
11
|
private roomsGateway;
|
|
11
|
-
|
|
12
|
+
private notificationsService;
|
|
13
|
+
constructor(roomsService: RoomsService, filesService: FilesService, jwtService: JwtService, roomsGateway: RoomsGateway, notificationsService: NotificationsService);
|
|
12
14
|
getToken(body: {
|
|
13
15
|
room: string;
|
|
14
16
|
permission: string;
|
|
@@ -17,9 +19,9 @@ export declare class RoomsController {
|
|
|
17
19
|
}>;
|
|
18
20
|
getUsers(userIds: string | string[]): Promise<any[]>;
|
|
19
21
|
searchUsers(req: Request, keyword: string, roomdId: string): Promise<string[]>;
|
|
20
|
-
getThreads(roomId: string): Promise<{
|
|
22
|
+
getThreads(req: Request, roomId: string): Promise<{
|
|
21
23
|
data: any;
|
|
22
|
-
inboxNotifications: any
|
|
24
|
+
inboxNotifications: any;
|
|
23
25
|
meta: {
|
|
24
26
|
nextCursor: any;
|
|
25
27
|
requestedAt: string;
|
|
@@ -30,9 +32,9 @@ export declare class RoomsController {
|
|
|
30
32
|
deletedThreads: any[];
|
|
31
33
|
deletedInboxNotifications: any[];
|
|
32
34
|
}>;
|
|
33
|
-
getThreadsDelta(roomId: string, since: string): Promise<{
|
|
35
|
+
getThreadsDelta(req: Request, roomId: string, since: string): Promise<{
|
|
34
36
|
data: any;
|
|
35
|
-
inboxNotifications: any
|
|
37
|
+
inboxNotifications: any;
|
|
36
38
|
meta: {
|
|
37
39
|
nextCursor: any;
|
|
38
40
|
requestedAt: string;
|
|
@@ -46,12 +48,35 @@ export declare class RoomsController {
|
|
|
46
48
|
createThread(req: Request, roomId: string, record: Record<string, any>): Promise<any>;
|
|
47
49
|
threadWithNotification(req: Request, roomId: string, threadId: string): Promise<{
|
|
48
50
|
thread: any;
|
|
51
|
+
inboxNotification: any;
|
|
49
52
|
}>;
|
|
50
53
|
threadMarkasResolved(req: Request, roomId: string, threadId: string): Promise<any>;
|
|
51
54
|
threadMarkasUnResolved(req: Request, roomId: string, threadId: string): Promise<any>;
|
|
52
55
|
createComment(req: Request, roomId: string, threadId: string, record: Record<string, any>): Promise<any>;
|
|
53
56
|
updateComment(req: Request, roomId: string, threadId: string, commentId: string, record: Record<string, any>): Promise<any>;
|
|
54
57
|
deleteComment(req: Request, roomId: string, threadId: string, commentId: string): Promise<{}>;
|
|
58
|
+
getInboxNotifications(req: Request, unread: string, limit: string): Promise<{
|
|
59
|
+
inboxNotifications: any;
|
|
60
|
+
threads: any[];
|
|
61
|
+
meta: {
|
|
62
|
+
nextCursor: any;
|
|
63
|
+
requestedAt: Date;
|
|
64
|
+
};
|
|
65
|
+
deletedThreads: any[];
|
|
66
|
+
deletedInboxNotifications: any[];
|
|
67
|
+
}>;
|
|
68
|
+
getInboxNotificationsSince(req: Request, since: string): Promise<{
|
|
69
|
+
inboxNotifications: any;
|
|
70
|
+
threads: any[];
|
|
71
|
+
meta: {
|
|
72
|
+
requestedAt: Date;
|
|
73
|
+
};
|
|
74
|
+
deletedThreads: any[];
|
|
75
|
+
deletedInboxNotifications: any[];
|
|
76
|
+
}>;
|
|
77
|
+
read(req: Request, roomId: string, inboxNotificationIds: string[]): Promise<{
|
|
78
|
+
data: any;
|
|
79
|
+
}>;
|
|
55
80
|
presignedUrls(attachmentIds: string[]): Promise<{
|
|
56
81
|
urls: string[];
|
|
57
82
|
}>;
|