@comasoft/nestjs 0.0.97 → 0.1.2
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 +31 -0
- package/dist/aws/aws-s3.service.d.ts +17 -0
- package/dist/aws/aws-s3.service.js +158 -0
- package/dist/aws/aws.module.d.ts +2 -0
- package/dist/aws/aws.module.js +25 -0
- package/dist/aws/aws.service.d.ts +3 -0
- package/dist/aws/aws.service.js +21 -0
- package/dist/aws/constants/storage.constant.d.ts +4 -0
- package/dist/aws/constants/storage.constant.js +25 -0
- package/dist/aws/dto/create-s3-presigned.dto.d.ts +12 -0
- package/dist/aws/dto/create-s3-presigned.dto.js +78 -0
- package/dist/aws/dto/index.d.ts +2 -0
- package/dist/aws/dto/index.js +18 -0
- package/dist/aws/dto/response-s3-presigned.dto.d.ts +30 -0
- package/dist/aws/dto/response-s3-presigned.dto.js +110 -0
- package/dist/aws/index.d.ts +4 -0
- package/dist/aws/index.js +20 -0
- package/dist/aws/types/s3.interface.d.ts +14 -0
- package/dist/aws/types/s3.interface.js +2 -0
- package/dist/aws/types/storage.interface.d.ts +19 -0
- package/dist/aws/types/storage.interface.js +2 -0
- package/dist/category/category.module.d.ts +2 -0
- package/dist/category/category.module.js +23 -0
- package/dist/category/category.service.d.ts +13 -0
- package/dist/category/category.service.js +124 -0
- package/dist/category/dto/create-category.dto.d.ts +7 -0
- package/dist/category/dto/create-category.dto.js +34 -0
- package/dist/category/dto/delete-category.dto.d.ts +3 -0
- package/dist/category/dto/delete-category.dto.js +6 -0
- package/dist/category/dto/index.d.ts +5 -0
- package/dist/category/dto/index.js +21 -0
- package/dist/category/dto/response-categories.dto.d.ts +12 -0
- package/dist/category/dto/response-categories.dto.js +52 -0
- package/dist/category/dto/update-category-sort.dto.d.ts +9 -0
- package/dist/category/dto/update-category-sort.dto.js +33 -0
- package/dist/category/dto/update-category.dto.d.ts +6 -0
- package/dist/category/dto/update-category.dto.js +9 -0
- package/dist/category/index.d.ts +3 -0
- package/dist/category/index.js +19 -0
- package/dist/comment/comment.module.d.ts +2 -0
- package/dist/comment/comment.module.js +23 -0
- package/dist/comment/comment.service.d.ts +33 -0
- package/dist/comment/comment.service.js +240 -0
- package/dist/comment/dto/create-comment.dto.d.ts +7 -0
- package/dist/comment/dto/create-comment.dto.js +41 -0
- package/dist/comment/dto/index.d.ts +3 -0
- package/dist/comment/dto/index.js +19 -0
- package/dist/comment/dto/response-comment.dto.d.ts +26 -0
- package/dist/comment/dto/response-comment.dto.js +97 -0
- package/dist/comment/dto/update-comment.dto.d.ts +4 -0
- package/dist/comment/dto/update-comment.dto.js +22 -0
- package/dist/comment/index.d.ts +3 -0
- package/dist/comment/index.js +19 -0
- package/dist/database/entities/category.entity.d.ts +14 -0
- package/dist/database/entities/category.entity.js +70 -0
- package/dist/database/entities/comment.entity.d.ts +16 -0
- package/dist/database/entities/comment.entity.js +77 -0
- package/dist/database/entities/config.entity.d.ts +8 -0
- package/dist/database/entities/config.entity.js +44 -0
- package/dist/database/entities/file.entity.d.ts +20 -0
- package/dist/database/entities/file.entity.js +91 -0
- package/dist/database/entities/index.d.ts +10 -0
- package/dist/database/entities/index.js +26 -0
- package/dist/database/entities/like.entity.d.ts +10 -0
- package/dist/database/entities/like.entity.js +49 -0
- package/dist/database/entities/logs-audit.entity.d.ts +16 -0
- package/dist/database/entities/logs-audit.entity.js +72 -0
- package/dist/database/entities/logs-event.entity.d.ts +16 -0
- package/dist/database/entities/logs-event.entity.js +72 -0
- package/dist/database/entities/notification-recipient.entity.d.ts +19 -0
- package/dist/database/entities/notification-recipient.entity.js +74 -0
- package/dist/database/entities/notification.entity.d.ts +18 -0
- package/dist/database/entities/notification.entity.js +69 -0
- package/dist/database/entities/role.entity.d.ts +13 -0
- package/dist/database/entities/role.entity.js +54 -0
- package/dist/database/entities/roles.entity.d.ts +12 -0
- package/dist/database/entities/roles.entity.js +1 -0
- package/dist/decorators/auth.decorator.factory.d.ts +1 -1
- package/dist/decorators/auth.decorator.factory.js +23 -2
- package/dist/decorators/delete-columns.decorator.js +1 -33
- package/dist/decorators/patch-body.decorator.js +20 -12
- package/dist/decorators/soft-delete.decorator.js +1 -15
- package/dist/decorators/timestamps.decorator.js +5 -13
- package/dist/dto/file.dto.d.ts +18 -0
- package/dist/dto/file.dto.js +70 -0
- package/dist/dto/index.d.ts +2 -0
- package/dist/dto/index.js +2 -0
- package/dist/dto/response-uid.dto.d.ts +2 -0
- package/dist/dto/response-uid.dto.js +8 -0
- package/dist/dto/update-ids.dto.d.ts +6 -1
- package/dist/dto/update-ids.dto.js +24 -10
- package/dist/dto/update-sort.dto.d.ts +9 -0
- package/dist/dto/update-sort.dto.js +50 -0
- package/dist/enums.common.d.ts +23 -0
- package/dist/enums.common.js +28 -1
- package/dist/events/event-bus.module.d.ts +2 -0
- package/dist/events/event-bus.module.js +44 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.js +20 -0
- package/dist/events/listeners/audit-event.listener.d.ts +9 -0
- package/dist/events/listeners/audit-event.listener.js +58 -0
- package/dist/events/listeners/index.d.ts +1 -0
- package/dist/events/listeners/index.js +17 -0
- package/dist/events/listeners/system-event.listener.d.ts +9 -0
- package/dist/events/listeners/system-event.listener.js +58 -0
- package/dist/events/services/event-logger.service.d.ts +5 -0
- package/dist/events/services/event-logger.service.js +34 -0
- package/dist/events/services/event-notification.service.d.ts +7 -0
- package/dist/events/services/event-notification.service.js +104 -0
- package/dist/events/services/event-storage.service.d.ts +11 -0
- package/dist/events/services/event-storage.service.js +79 -0
- package/dist/events/services/index.d.ts +4 -0
- package/dist/events/services/index.js +20 -0
- package/dist/events/services/token.service.d.ts +23 -0
- package/dist/events/services/token.service.js +88 -0
- package/dist/events/types/audit-events.type.d.ts +12 -0
- package/dist/events/types/audit-events.type.js +2 -0
- package/dist/events/types/index.d.ts +18 -0
- package/dist/events/types/index.js +17 -0
- package/dist/filters/http-exception.filter.d.ts +4 -0
- package/dist/filters/http-exception.filter.js +26 -4
- package/dist/guards/auth.guard.d.ts +3 -1
- package/dist/guards/auth.guard.js +33 -11
- package/dist/index.d.ts +20 -8
- package/dist/index.js +12 -0
- package/dist/library.module.d.ts +2 -0
- package/dist/library.module.js +20 -0
- package/dist/like/dto/create-like.dto.d.ts +7 -0
- package/dist/like/dto/create-like.dto.js +47 -0
- package/dist/like/dto/index.d.ts +2 -0
- package/dist/like/dto/index.js +18 -0
- package/dist/like/dto/response-like.dto.d.ts +19 -0
- package/dist/like/dto/response-like.dto.js +79 -0
- package/dist/like/index.d.ts +3 -0
- package/dist/like/index.js +19 -0
- package/dist/like/like.module.d.ts +2 -0
- package/dist/like/like.module.js +23 -0
- package/dist/like/like.service.d.ts +13 -0
- package/dist/like/like.service.js +155 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.js +18 -0
- package/dist/logger/pino-options.d.ts +31 -0
- package/dist/logger/pino-options.js +77 -0
- package/dist/logger/pino-pretty-transport.d.ts +1 -0
- package/dist/logger/pino-pretty-transport.js +164 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/modules/redis.module.d.ts +9 -0
- package/dist/modules/redis.module.js +1 -0
- package/dist/notifications/index.d.ts +70 -0
- package/dist/notifications/index.js +18 -0
- package/dist/notifications/notification.module.d.ts +2 -0
- package/dist/notifications/notification.module.js +32 -0
- package/dist/notifications/services/email.service.d.ts +31 -0
- package/dist/notifications/services/email.service.js +69 -0
- package/dist/notifications/services/index.d.ts +7 -0
- package/dist/notifications/services/index.js +23 -0
- package/dist/notifications/services/kakao.service.d.ts +41 -0
- package/dist/notifications/services/kakao.service.js +94 -0
- package/dist/notifications/services/message-template.service.d.ts +15 -0
- package/dist/notifications/services/message-template.service.js +74 -0
- package/dist/notifications/services/notification-send.service.d.ts +30 -0
- package/dist/notifications/services/notification-send.service.js +146 -0
- package/dist/notifications/services/notification.service.d.ts +37 -0
- package/dist/notifications/services/notification.service.js +125 -0
- package/dist/notifications/services/slack.service.d.ts +11 -0
- package/dist/notifications/services/slack.service.js +53 -0
- package/dist/notifications/services/sms.service.d.ts +19 -0
- package/dist/notifications/services/sms.service.js +62 -0
- package/dist/redis/index.d.ts +2 -0
- package/dist/redis/index.js +18 -0
- package/dist/redis/redis-constraint.d.ts +1 -0
- package/dist/redis/redis-constraint.js +4 -0
- package/dist/redis/redis.module.d.ts +8 -0
- package/dist/redis/redis.module.js +62 -0
- package/dist/redis/redis.service.d.ts +12 -0
- package/dist/redis/redis.service.js +76 -0
- package/dist/role/dto/create-role.dto.d.ts +5 -0
- package/dist/role/dto/create-role.dto.js +41 -0
- package/dist/role/dto/index.d.ts +3 -0
- package/dist/role/dto/index.js +19 -0
- package/dist/role/dto/response-roles.dto.d.ts +15 -0
- package/dist/role/dto/response-roles.dto.js +62 -0
- package/dist/role/dto/update-role.dto.d.ts +6 -0
- package/dist/role/dto/update-role.dto.js +9 -0
- package/dist/role/index.d.ts +3 -0
- package/dist/role/index.js +19 -0
- package/dist/role/role.module.d.ts +2 -0
- package/dist/role/role.module.js +23 -0
- package/dist/role/role.service.d.ts +17 -0
- package/dist/role/role.service.js +144 -0
- package/dist/services/file.service.d.ts +55 -0
- package/dist/services/file.service.js +82 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +18 -0
- package/dist/services/message-template.service.d.ts +15 -0
- package/dist/services/message-template.service.js +1 -0
- package/dist/services/permission-checker.service.d.ts +38 -0
- package/dist/services/permission-checker.service.js +65 -0
- package/dist/shared/error-codes.d.ts +5 -0
- package/dist/shared/error-codes.js +9 -0
- package/dist/utils/common.utils.d.ts +2 -0
- package/dist/utils/common.utils.js +11 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/object-diff.d.ts +1 -0
- package/dist/utils/object-diff.js +33 -0
- package/package.json +61 -16
- package/eslint.config.js +0 -31
- package/tsconfig.build.json +0 -19
- package/tsconfig.json +0 -18
|
@@ -0,0 +1,69 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.EmailService = void 0;
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
const config_1 = require("@nestjs/config");
|
|
24
|
+
let EmailService = class EmailService {
|
|
25
|
+
constructor(configService) {
|
|
26
|
+
this.configService = configService;
|
|
27
|
+
}
|
|
28
|
+
send(recipients) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const provider = this.configService.get('EMAIL_PROVIDER');
|
|
31
|
+
if (!provider || !this.configService.get('EMAIL_FROM')) {
|
|
32
|
+
throw new Error('EMAIL_PROVIDER or EMAIL_FROM is not set');
|
|
33
|
+
}
|
|
34
|
+
if (provider === 'aws') {
|
|
35
|
+
return this.sendAws(recipients);
|
|
36
|
+
}
|
|
37
|
+
return [];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
sendAws(recipients) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
console.log('📧 [EMAIL] AWS SES 배열 발송:', {
|
|
43
|
+
count: recipients.length,
|
|
44
|
+
from: this.configService.get('EMAIL_FROM'),
|
|
45
|
+
provider: this.configService.get('EMAIL_PROVIDER'),
|
|
46
|
+
recipients: recipients.map(r => ({
|
|
47
|
+
user_id: r.user_id,
|
|
48
|
+
recipient: r.recipient,
|
|
49
|
+
subject: r.subject,
|
|
50
|
+
text: r.text.substring(0, 50) + (r.text.length > 50 ? '...' : ''),
|
|
51
|
+
variables: r.variables
|
|
52
|
+
})),
|
|
53
|
+
timestamp: new Date().toISOString()
|
|
54
|
+
});
|
|
55
|
+
return recipients.map(r => ({
|
|
56
|
+
user_id: r.user_id,
|
|
57
|
+
recipient: r.recipient,
|
|
58
|
+
success: true,
|
|
59
|
+
messageId: `aws-${Date.now()}-${r.user_id}`,
|
|
60
|
+
status: 'sent'
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.EmailService = EmailService;
|
|
66
|
+
exports.EmailService = EmailService = __decorate([
|
|
67
|
+
(0, common_1.Injectable)(),
|
|
68
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
69
|
+
], EmailService);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './notification.service';
|
|
2
|
+
export * from './notification-send.service';
|
|
3
|
+
export * from './message-template.service';
|
|
4
|
+
export * from './email.service';
|
|
5
|
+
export * from './kakao.service';
|
|
6
|
+
export * from './sms.service';
|
|
7
|
+
export * from './slack.service';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./notification.service"), exports);
|
|
18
|
+
__exportStar(require("./notification-send.service"), exports);
|
|
19
|
+
__exportStar(require("./message-template.service"), exports);
|
|
20
|
+
__exportStar(require("./email.service"), exports);
|
|
21
|
+
__exportStar(require("./kakao.service"), exports);
|
|
22
|
+
__exportStar(require("./sms.service"), exports);
|
|
23
|
+
__exportStar(require("./slack.service"), exports);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
export declare class KakaoService {
|
|
3
|
+
private readonly configService;
|
|
4
|
+
constructor(configService: ConfigService);
|
|
5
|
+
send(recipients: Array<{
|
|
6
|
+
recipient: string;
|
|
7
|
+
user_id: number;
|
|
8
|
+
template_code: string;
|
|
9
|
+
variables?: Record<string, any>;
|
|
10
|
+
}>): Promise<{
|
|
11
|
+
user_id: number;
|
|
12
|
+
recipient: string;
|
|
13
|
+
success: boolean;
|
|
14
|
+
messageId: string;
|
|
15
|
+
status: string;
|
|
16
|
+
}[]>;
|
|
17
|
+
sendAligo(recipients: Array<{
|
|
18
|
+
recipient: string;
|
|
19
|
+
user_id: number;
|
|
20
|
+
template_code: string;
|
|
21
|
+
variables?: Record<string, any>;
|
|
22
|
+
}>): Promise<{
|
|
23
|
+
user_id: number;
|
|
24
|
+
recipient: string;
|
|
25
|
+
success: boolean;
|
|
26
|
+
messageId: string;
|
|
27
|
+
status: string;
|
|
28
|
+
}[]>;
|
|
29
|
+
sendPpurio(recipients: Array<{
|
|
30
|
+
recipient: string;
|
|
31
|
+
user_id: number;
|
|
32
|
+
template_code: string;
|
|
33
|
+
variables?: Record<string, any>;
|
|
34
|
+
}>): Promise<{
|
|
35
|
+
user_id: number;
|
|
36
|
+
recipient: string;
|
|
37
|
+
success: boolean;
|
|
38
|
+
messageId: string;
|
|
39
|
+
status: string;
|
|
40
|
+
}[]>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.KakaoService = void 0;
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
const config_1 = require("@nestjs/config");
|
|
24
|
+
let KakaoService = class KakaoService {
|
|
25
|
+
constructor(configService) {
|
|
26
|
+
this.configService = configService;
|
|
27
|
+
}
|
|
28
|
+
send(recipients) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const provider = this.configService.get('KAKAO_PROVIDER');
|
|
31
|
+
if (!provider || !this.configService.get('KAKAO_FROM')) {
|
|
32
|
+
throw new Error('KAKAO_PROVIDER or KAKAO_FROM is not set');
|
|
33
|
+
}
|
|
34
|
+
if (provider === 'aligo') {
|
|
35
|
+
return this.sendAligo(recipients);
|
|
36
|
+
}
|
|
37
|
+
else if (provider === 'ppurio') {
|
|
38
|
+
return this.sendPpurio(recipients);
|
|
39
|
+
}
|
|
40
|
+
return [];
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
sendAligo(recipients) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
console.log('📱 [KAKAO] Aligo 배열 발송:', {
|
|
46
|
+
count: recipients.length,
|
|
47
|
+
from: this.configService.get('KAKAO_FROM'),
|
|
48
|
+
provider: 'aligo',
|
|
49
|
+
recipients: recipients.map(r => ({
|
|
50
|
+
user_id: r.user_id,
|
|
51
|
+
recipient: r.recipient,
|
|
52
|
+
template_code: r.template_code,
|
|
53
|
+
variables: r.variables
|
|
54
|
+
})),
|
|
55
|
+
timestamp: new Date().toISOString()
|
|
56
|
+
});
|
|
57
|
+
return recipients.map(r => ({
|
|
58
|
+
user_id: r.user_id,
|
|
59
|
+
recipient: r.recipient,
|
|
60
|
+
success: true,
|
|
61
|
+
messageId: `aligo-${Date.now()}-${r.user_id}`,
|
|
62
|
+
status: 'sent'
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
sendPpurio(recipients) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
console.log('📱 [KAKAO] Ppurio 배열 발송:', {
|
|
69
|
+
count: recipients.length,
|
|
70
|
+
from: this.configService.get('KAKAO_FROM'),
|
|
71
|
+
provider: 'ppurio',
|
|
72
|
+
recipients: recipients.map(r => ({
|
|
73
|
+
user_id: r.user_id,
|
|
74
|
+
recipient: r.recipient,
|
|
75
|
+
template_code: r.template_code,
|
|
76
|
+
variables: r.variables
|
|
77
|
+
})),
|
|
78
|
+
timestamp: new Date().toISOString()
|
|
79
|
+
});
|
|
80
|
+
return recipients.map(r => ({
|
|
81
|
+
user_id: r.user_id,
|
|
82
|
+
recipient: r.recipient,
|
|
83
|
+
success: true,
|
|
84
|
+
messageId: `ppurio-${Date.now()}-${r.user_id}`,
|
|
85
|
+
status: 'sent'
|
|
86
|
+
}));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
exports.KakaoService = KakaoService;
|
|
91
|
+
exports.KakaoService = KakaoService = __decorate([
|
|
92
|
+
(0, common_1.Injectable)(),
|
|
93
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
94
|
+
], KakaoService);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { Config } from '../../database/entities';
|
|
3
|
+
export declare class MessageTemplateService {
|
|
4
|
+
private configRepository;
|
|
5
|
+
constructor(configRepository: Repository<Config>);
|
|
6
|
+
getTemplate(type: 'email' | 'sms' | 'slack' | 'kakao', templateKey: string): Promise<any>;
|
|
7
|
+
getTemplates(): Promise<Record<string, any>>;
|
|
8
|
+
updateTemplates(templates: any): Promise<void>;
|
|
9
|
+
renderTemplate(template: {
|
|
10
|
+
content: string;
|
|
11
|
+
variables: string[];
|
|
12
|
+
required_vars: string[];
|
|
13
|
+
default_vars: Record<string, any>;
|
|
14
|
+
}, variables: Record<string, any>): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
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
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.MessageTemplateService = void 0;
|
|
25
|
+
const common_1 = require("@nestjs/common");
|
|
26
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
27
|
+
const typeorm_2 = require("typeorm");
|
|
28
|
+
const entities_1 = require("../../database/entities");
|
|
29
|
+
let MessageTemplateService = class MessageTemplateService {
|
|
30
|
+
constructor(configRepository) {
|
|
31
|
+
this.configRepository = configRepository;
|
|
32
|
+
}
|
|
33
|
+
getTemplate(type, templateKey) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a;
|
|
36
|
+
const templates = yield this.getTemplates();
|
|
37
|
+
return (_a = templates[type]) === null || _a === void 0 ? void 0 : _a[templateKey];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
getTemplates() {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const config = yield this.configRepository.findOne({
|
|
43
|
+
where: { key: 'message_templates', is_active: true },
|
|
44
|
+
});
|
|
45
|
+
return (config === null || config === void 0 ? void 0 : config.value) || {};
|
|
46
|
+
return {};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
updateTemplates(templates) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
yield this.configRepository.update({ key: 'message_templates' }, { value: templates, updated_at: new Date() });
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
renderTemplate(template, variables) {
|
|
55
|
+
const missing = template.required_vars.filter((v) => { var _a; return variables[v] === undefined && ((_a = template.default_vars) === null || _a === void 0 ? void 0 : _a[v]) === undefined; });
|
|
56
|
+
if (missing.length > 0) {
|
|
57
|
+
throw new Error(`Missing required variables: ${missing.join(', ')}`);
|
|
58
|
+
}
|
|
59
|
+
return template.content.replace(/\{\{(\w+)\}\}/g, (match, key) => {
|
|
60
|
+
var _a;
|
|
61
|
+
if (variables[key] !== undefined)
|
|
62
|
+
return variables[key];
|
|
63
|
+
if (((_a = template.default_vars) === null || _a === void 0 ? void 0 : _a[key]) !== undefined)
|
|
64
|
+
return template.default_vars[key];
|
|
65
|
+
return '';
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.MessageTemplateService = MessageTemplateService;
|
|
70
|
+
exports.MessageTemplateService = MessageTemplateService = __decorate([
|
|
71
|
+
(0, common_1.Injectable)(),
|
|
72
|
+
__param(0, (0, typeorm_1.InjectRepository)(entities_1.Config)),
|
|
73
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
74
|
+
], MessageTemplateService);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NotificationPayload } from '..';
|
|
2
|
+
import { EmailService } from './email.service';
|
|
3
|
+
import { KakaoService } from './kakao.service';
|
|
4
|
+
import { MessageTemplateService } from './message-template.service';
|
|
5
|
+
import { SlackService } from './slack.service';
|
|
6
|
+
import { SmsService } from './sms.service';
|
|
7
|
+
export declare class NotificationSendService {
|
|
8
|
+
private readonly emailService;
|
|
9
|
+
private readonly smsService;
|
|
10
|
+
private readonly kakaoService;
|
|
11
|
+
private readonly slackService;
|
|
12
|
+
private readonly messageTemplateService;
|
|
13
|
+
constructor(emailService: EmailService, smsService: SmsService, kakaoService: KakaoService, slackService: SlackService, messageTemplateService: MessageTemplateService);
|
|
14
|
+
send(payload: NotificationPayload): Promise<{
|
|
15
|
+
user_id: number;
|
|
16
|
+
recipient: string;
|
|
17
|
+
success: boolean;
|
|
18
|
+
messageId: string;
|
|
19
|
+
status: string;
|
|
20
|
+
}[] | {
|
|
21
|
+
channel: string;
|
|
22
|
+
success: boolean;
|
|
23
|
+
messageId: string;
|
|
24
|
+
status: string;
|
|
25
|
+
}[]>;
|
|
26
|
+
private sendEmail;
|
|
27
|
+
private sendSms;
|
|
28
|
+
private sendKakao;
|
|
29
|
+
private sendSlack;
|
|
30
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.NotificationSendService = void 0;
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
const email_service_1 = require("./email.service");
|
|
24
|
+
const kakao_service_1 = require("./kakao.service");
|
|
25
|
+
const message_template_service_1 = require("./message-template.service");
|
|
26
|
+
const slack_service_1 = require("./slack.service");
|
|
27
|
+
const sms_service_1 = require("./sms.service");
|
|
28
|
+
let NotificationSendService = class NotificationSendService {
|
|
29
|
+
constructor(emailService, smsService, kakaoService, slackService, messageTemplateService) {
|
|
30
|
+
this.emailService = emailService;
|
|
31
|
+
this.smsService = smsService;
|
|
32
|
+
this.kakaoService = kakaoService;
|
|
33
|
+
this.slackService = slackService;
|
|
34
|
+
this.messageTemplateService = messageTemplateService;
|
|
35
|
+
}
|
|
36
|
+
send(payload) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
switch (payload.type) {
|
|
39
|
+
case 'email':
|
|
40
|
+
return this.sendEmail(payload);
|
|
41
|
+
case 'sms':
|
|
42
|
+
return this.sendSms(payload);
|
|
43
|
+
case 'kakao':
|
|
44
|
+
return this.sendKakao(payload);
|
|
45
|
+
case 'slack':
|
|
46
|
+
return this.sendSlack(payload);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
sendEmail(payload) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const emailRecipients = [];
|
|
53
|
+
for (const recipient of payload.recipients) {
|
|
54
|
+
let content;
|
|
55
|
+
let subject;
|
|
56
|
+
if (payload.template_key) {
|
|
57
|
+
const template = yield this.messageTemplateService.getTemplate('email', payload.template_key);
|
|
58
|
+
if (!template)
|
|
59
|
+
throw new Error('Template not found');
|
|
60
|
+
const mergedVariables = Object.assign(Object.assign({}, payload.variables), recipient.variables);
|
|
61
|
+
content = this.messageTemplateService.renderTemplate(template, mergedVariables);
|
|
62
|
+
subject = template.subject;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (!payload.subject || !payload.body)
|
|
66
|
+
throw new Error('subject, body is required');
|
|
67
|
+
content = payload.body;
|
|
68
|
+
subject = payload.subject;
|
|
69
|
+
}
|
|
70
|
+
emailRecipients.push({
|
|
71
|
+
recipient: recipient.recipient,
|
|
72
|
+
user_id: recipient.user_id,
|
|
73
|
+
subject,
|
|
74
|
+
text: content,
|
|
75
|
+
variables: recipient.variables
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return yield this.emailService.send(emailRecipients);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
sendSms(payload) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const smsRecipients = [];
|
|
84
|
+
for (const recipient of payload.recipients) {
|
|
85
|
+
let content;
|
|
86
|
+
if (payload.template_key) {
|
|
87
|
+
const template = yield this.messageTemplateService.getTemplate('sms', payload.template_key);
|
|
88
|
+
if (!template)
|
|
89
|
+
throw new Error('Template not found');
|
|
90
|
+
const mergedVariables = Object.assign(Object.assign({}, payload.variables), recipient.variables);
|
|
91
|
+
content = this.messageTemplateService.renderTemplate(template, mergedVariables);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (!payload.message)
|
|
95
|
+
throw new Error('message is required');
|
|
96
|
+
content = payload.message;
|
|
97
|
+
}
|
|
98
|
+
smsRecipients.push({
|
|
99
|
+
recipient: recipient.recipient,
|
|
100
|
+
user_id: recipient.user_id,
|
|
101
|
+
message: content,
|
|
102
|
+
variables: recipient.variables
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return yield this.smsService.send(smsRecipients);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
sendKakao(payload) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const kakaoRecipients = payload.recipients.map(recipient => ({
|
|
111
|
+
recipient: recipient.recipient,
|
|
112
|
+
user_id: recipient.user_id,
|
|
113
|
+
template_code: payload.template_key,
|
|
114
|
+
variables: Object.assign(Object.assign({}, payload.variables), recipient.variables)
|
|
115
|
+
}));
|
|
116
|
+
return yield this.kakaoService.send(kakaoRecipients);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
sendSlack(payload) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
let content;
|
|
122
|
+
if (payload.template_key) {
|
|
123
|
+
const template = yield this.messageTemplateService.getTemplate('slack', payload.template_key);
|
|
124
|
+
if (!template)
|
|
125
|
+
throw new Error('Template not found');
|
|
126
|
+
content = this.messageTemplateService.renderTemplate(template, payload.variables || {});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
if (!payload.message)
|
|
130
|
+
throw new Error('message is required');
|
|
131
|
+
content = payload.message;
|
|
132
|
+
}
|
|
133
|
+
const result = yield this.slackService.send(payload.channel, content);
|
|
134
|
+
return [result];
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
exports.NotificationSendService = NotificationSendService;
|
|
139
|
+
exports.NotificationSendService = NotificationSendService = __decorate([
|
|
140
|
+
(0, common_1.Injectable)(),
|
|
141
|
+
__metadata("design:paramtypes", [email_service_1.EmailService,
|
|
142
|
+
sms_service_1.SmsService,
|
|
143
|
+
kakao_service_1.KakaoService,
|
|
144
|
+
slack_service_1.SlackService,
|
|
145
|
+
message_template_service_1.MessageTemplateService])
|
|
146
|
+
], NotificationSendService);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { Notification, NotificationRecipient } from '../../database/entities';
|
|
4
|
+
import { NOTIFICATION_STATUS } from '../../enums.common';
|
|
5
|
+
export declare class NotificationService {
|
|
6
|
+
private readonly notificationRepository;
|
|
7
|
+
private readonly notificationRecipientRepository;
|
|
8
|
+
private readonly configService;
|
|
9
|
+
constructor(notificationRepository: Repository<Notification>, notificationRecipientRepository: Repository<NotificationRecipient>, configService: ConfigService);
|
|
10
|
+
create({ type, template_key, title, content, recipients, variables, }: {
|
|
11
|
+
type: string;
|
|
12
|
+
template_key: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
content?: string;
|
|
15
|
+
recipients: Array<{
|
|
16
|
+
user_id: number;
|
|
17
|
+
recipient: string;
|
|
18
|
+
variables?: Record<string, any>;
|
|
19
|
+
}>;
|
|
20
|
+
variables?: Record<string, any>;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
notification: {
|
|
23
|
+
type: string;
|
|
24
|
+
template_key: string;
|
|
25
|
+
title: string;
|
|
26
|
+
content: string;
|
|
27
|
+
sender: string;
|
|
28
|
+
status: NOTIFICATION_STATUS.PENDING;
|
|
29
|
+
} & Notification;
|
|
30
|
+
recipients: NotificationRecipient[];
|
|
31
|
+
}>;
|
|
32
|
+
private getSenderByType;
|
|
33
|
+
findAll(): Promise<Notification[]>;
|
|
34
|
+
find(id: number): Promise<Notification>;
|
|
35
|
+
resend(notification_id: number, user_id?: number): Promise<NotificationRecipient[]>;
|
|
36
|
+
markAsRead(notification_id: number, user_id: number): Promise<NotificationRecipient>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
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
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.NotificationService = void 0;
|
|
25
|
+
const common_1 = require("@nestjs/common");
|
|
26
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
27
|
+
const config_1 = require("@nestjs/config");
|
|
28
|
+
const typeorm_2 = require("typeorm");
|
|
29
|
+
const entities_1 = require("../../database/entities");
|
|
30
|
+
const enums_common_1 = require("../../enums.common");
|
|
31
|
+
let NotificationService = class NotificationService {
|
|
32
|
+
constructor(notificationRepository, notificationRecipientRepository, configService) {
|
|
33
|
+
this.notificationRepository = notificationRepository;
|
|
34
|
+
this.notificationRecipientRepository = notificationRecipientRepository;
|
|
35
|
+
this.configService = configService;
|
|
36
|
+
}
|
|
37
|
+
create(_a) {
|
|
38
|
+
return __awaiter(this, arguments, void 0, function* ({ type, template_key, title, content, recipients, variables, }) {
|
|
39
|
+
const sender = this.getSenderByType(type);
|
|
40
|
+
const notification = yield this.notificationRepository.save({
|
|
41
|
+
type,
|
|
42
|
+
template_key,
|
|
43
|
+
title,
|
|
44
|
+
content,
|
|
45
|
+
sender,
|
|
46
|
+
status: enums_common_1.NOTIFICATION_STATUS.PENDING,
|
|
47
|
+
});
|
|
48
|
+
const notificationRecipients = recipients.map((recipient) => this.notificationRecipientRepository.create({
|
|
49
|
+
notification_id: notification.id,
|
|
50
|
+
user_id: recipient.user_id,
|
|
51
|
+
recipient: recipient.recipient,
|
|
52
|
+
variables: recipient.variables,
|
|
53
|
+
status: enums_common_1.NOTIFICATION_STATUS.PENDING,
|
|
54
|
+
}));
|
|
55
|
+
yield this.notificationRecipientRepository.save(notificationRecipients);
|
|
56
|
+
return { notification, recipients: notificationRecipients };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getSenderByType(type) {
|
|
60
|
+
switch (type) {
|
|
61
|
+
case 'email':
|
|
62
|
+
return this.configService.get('EMAIL_FROM') || 'noreply@example.com';
|
|
63
|
+
case 'sms':
|
|
64
|
+
return this.configService.get('SMS_FROM') || '';
|
|
65
|
+
case 'kakao':
|
|
66
|
+
return this.configService.get('KAKAO_FROM') || '';
|
|
67
|
+
case 'slack':
|
|
68
|
+
return this.configService.get('SLACK_CHANNEL') || '';
|
|
69
|
+
default:
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
findAll() {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
return this.notificationRepository.find({
|
|
76
|
+
relations: ['recipients'],
|
|
77
|
+
order: { created_at: 'DESC' },
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
find(id) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
return this.notificationRepository.findOne({
|
|
84
|
+
where: { id },
|
|
85
|
+
relations: ['recipients'],
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
resend(notification_id, user_id) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const recipients = yield this.notificationRecipientRepository.find({
|
|
92
|
+
where: user_id ? { notification_id, user_id } : { notification_id },
|
|
93
|
+
});
|
|
94
|
+
for (const recipient of recipients) {
|
|
95
|
+
recipient.status = enums_common_1.NOTIFICATION_STATUS.PENDING;
|
|
96
|
+
recipient.failed_at = null;
|
|
97
|
+
recipient.reason_failed = null;
|
|
98
|
+
yield this.notificationRecipientRepository.save(recipient);
|
|
99
|
+
}
|
|
100
|
+
return recipients;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
markAsRead(notification_id, user_id) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const recipient = yield this.notificationRecipientRepository.findOne({
|
|
106
|
+
where: { notification_id, user_id },
|
|
107
|
+
});
|
|
108
|
+
if (recipient) {
|
|
109
|
+
recipient.status = enums_common_1.NOTIFICATION_STATUS.READ;
|
|
110
|
+
recipient.read_at = new Date();
|
|
111
|
+
yield this.notificationRecipientRepository.save(recipient);
|
|
112
|
+
}
|
|
113
|
+
return recipient;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
exports.NotificationService = NotificationService;
|
|
118
|
+
exports.NotificationService = NotificationService = __decorate([
|
|
119
|
+
(0, common_1.Injectable)(),
|
|
120
|
+
__param(0, (0, typeorm_1.InjectRepository)(entities_1.Notification)),
|
|
121
|
+
__param(1, (0, typeorm_1.InjectRepository)(entities_1.NotificationRecipient)),
|
|
122
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
123
|
+
typeorm_2.Repository,
|
|
124
|
+
config_1.ConfigService])
|
|
125
|
+
], NotificationService);
|