diff --git a/packages/relay/scripts/notice_shop.ts b/packages/relay/scripts/notice_shop.ts new file mode 100644 index 00000000..c7a4e198 --- /dev/null +++ b/packages/relay/scripts/notice_shop.ts @@ -0,0 +1,36 @@ +import { BOACoin } from "../src/common/Amount"; + +import "@nomiclabs/hardhat-ethers"; +import * as hre from "hardhat"; +import { INotificationEventHandler, NotificationSender } from "../src/delegator/NotificationSender"; + +import { Config } from "../src/common/Config"; + +async function main() { + const provider = hre.ethers.provider; + const account = "0x9E8549cc1B5b9036AC410Ed11966BB3c6B94A77d"; + const balance = await provider.getBalance(account); + console.log(`${account} : ${new BOACoin(balance).toBOAString()}`); + + const notificationEventHandler: INotificationEventHandler = { + receive: async (to: string, title: string, body: string, data: any) => { + console.log(to, title); + }, + }; + // Create with the arguments and read from file + const config = new Config(); + config.readFromFile("config/config.yaml"); + const notification: NotificationSender = new NotificationSender(config, notificationEventHandler); + + await notification.send( + "ExponentPushToken[gr9g1_GA_54W9mUfYMYPtG]", + "상점 푸쉬 테스트", + "구매처 : 마이클2, 구매 금액 : 100 PHP, 포인트 사용 : 100 POINT", + { type: "cancel" } + ); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/packages/relay/scripts/notice_user.ts b/packages/relay/scripts/notice_user.ts new file mode 100644 index 00000000..95144f15 --- /dev/null +++ b/packages/relay/scripts/notice_user.ts @@ -0,0 +1,36 @@ +import { BOACoin } from "../src/common/Amount"; + +import "@nomiclabs/hardhat-ethers"; +import * as hre from "hardhat"; +import { INotificationEventHandler, NotificationSender } from "../src/delegator/NotificationSender"; + +import { Config } from "../src/common/Config"; + +async function main() { + const provider = hre.ethers.provider; + const account = "0x9E8549cc1B5b9036AC410Ed11966BB3c6B94A77d"; + const balance = await provider.getBalance(account); + console.log(`${account} : ${new BOACoin(balance).toBOAString()}`); + + const notificationEventHandler: INotificationEventHandler = { + receive: async (to: string, title: string, body: string, data: any) => { + console.log(to, title); + }, + }; + // Create with the arguments and read from file + const config = new Config(); + config.readFromFile("config/config.yaml"); + const notification: NotificationSender = new NotificationSender(config, notificationEventHandler); + + await notification.send( + "ExponentPushToken[s__I-xJSSmcJCfLRPSobU_]", + "사용자 푸쉬 테스트", + "구매처 : 마이클2, 구매 금액 : 100 PHP, 포인트 사용 : 100 POINT", + { type: "cancel" } + ); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/packages/relay/src/routers/PaymentRouter.ts b/packages/relay/src/routers/PaymentRouter.ts index 196ca7aa..a0b59818 100644 --- a/packages/relay/src/routers/PaymentRouter.ts +++ b/packages/relay/src/routers/PaymentRouter.ts @@ -530,7 +530,7 @@ export class PaymentRouter { if (mobileData !== undefined) { // tslint:disable-next-line:one-variable-per-declaration let title, shopLabel, amountLabel, pointLabel: string; - if (mobileData.language === "kr") { + if (mobileData.language === "ko") { title = "포인트 사용 알림"; shopLabel = "구매처"; amountLabel = "구매 금액"; @@ -559,6 +559,7 @@ export class PaymentRouter { ); contents.push(`${pointLabel} : ${new Amount(item.paidPoint, 18).toDisplayString(true, 0)} POINT`); + logger.info(`Notification - to: ${to}, title: ${title}`); await this._sender.send(to, title, contents.join(", "), data); } @@ -1097,7 +1098,7 @@ export class PaymentRouter { /// 상점주에게 메세지 발송 // tslint:disable-next-line:one-variable-per-declaration let title, shopLabel, amountLabel, pointLabel: string; - if (mobileData.language === "kr") { + if (mobileData.language === "ko") { title = "마일리지 사용 취소 알림"; shopLabel = "구매처"; amountLabel = "구매 금액"; @@ -1125,6 +1126,7 @@ export class PaymentRouter { ); contents.push(`${pointLabel} : ${new Amount(item.paidPoint, 18).toDisplayString(true, 0)} POINT`); + logger.info(`Notification - to: ${to}, title: ${title}`); await this._sender.send(to, title, contents.join(", "), data); } diff --git a/packages/relay/src/routers/ShopRouter.ts b/packages/relay/src/routers/ShopRouter.ts index 698ab414..1fda9286 100644 --- a/packages/relay/src/routers/ShopRouter.ts +++ b/packages/relay/src/routers/ShopRouter.ts @@ -624,7 +624,7 @@ export class ShopRouter { let title: string; let shopLabel: string; let currencyLabel: string; - if (mobileData.language === "kr") { + if (mobileData.language === "ko") { title = "상점 정보 변경 요청"; shopLabel = "상점이름"; currencyLabel = "정산 환률 심벌"; @@ -644,6 +644,7 @@ export class ShopRouter { }; contents.push(`${shopLabel} : ${item.name}`); contents.push(`${currencyLabel} : ${item.currency}`); + logger.info(`Notification - to: ${to}, title: ${title}`); await this._sender.send(to, title, contents.join(", "), data); } @@ -897,7 +898,7 @@ export class ShopRouter { let statusLabel: string; let activeLabel: string; let inactiveLabel: string; - if (mobileData.language === "kr") { + if (mobileData.language === "ko") { title = "상점 상태 변경 요청"; shopLabel = "상점이름"; statusLabel = "변경될 상태값"; @@ -917,6 +918,7 @@ export class ShopRouter { contents.push( `${statusLabel} : ${item.status === ContractShopStatus.ACTIVE ? activeLabel : inactiveLabel}` ); + logger.info(`Notification - to: ${to}, title: ${title}`); await this._sender.send(to, title, contents.join(", "), data); }