Skip to content

Commit

Permalink
Fix a language of Notification
Browse files Browse the repository at this point in the history
  • Loading branch information
danial303065 committed Aug 12, 2024
1 parent fc52d32 commit b99ddc5
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
36 changes: 36 additions & 0 deletions packages/relay/scripts/notice_shop.ts
Original file line number Diff line number Diff line change
@@ -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;
});
36 changes: 36 additions & 0 deletions packages/relay/scripts/notice_user.ts
Original file line number Diff line number Diff line change
@@ -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;
});
6 changes: 4 additions & 2 deletions packages/relay/src/routers/PaymentRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "구매 금액";
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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 = "구매 금액";
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 4 additions & 2 deletions packages/relay/src/routers/ShopRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "정산 환률 심벌";
Expand All @@ -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);
}

Expand Down Expand Up @@ -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 = "변경될 상태값";
Expand All @@ -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);
}

Expand Down

0 comments on commit b99ddc5

Please sign in to comment.