refactor: update currency symbols in feed

This commit is contained in:
moonrailgun 2024-10-27 03:16:06 +08:00
parent 09d0f02d84
commit 98298c4367
3 changed files with 13 additions and 2 deletions

View File

@ -486,6 +486,9 @@ importers:
dotenv: dotenv:
specifier: ^16.3.1 specifier: ^16.3.1
version: 16.3.1 version: 16.3.1
easy-currency-symbol:
specifier: ^1.0.1
version: 1.0.1
express: express:
specifier: ^4.18.2 specifier: ^4.18.2
version: 4.18.2 version: 4.18.2
@ -6204,6 +6207,9 @@ packages:
eastasianwidth@0.2.0: eastasianwidth@0.2.0:
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
easy-currency-symbol@1.0.1:
resolution: {integrity: sha512-M8ugWXSnV5utVTJd4uLOsXqg/sv8Ca7yrDvbSy01mQ52u2XxNnoJ0+tenh3gYCvcceRRLkG/AzIVP/rdjKGuAg==}
ecdsa-sig-formatter@1.0.11: ecdsa-sig-formatter@1.0.11:
resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==} resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==}
@ -10321,6 +10327,7 @@ packages:
react-beautiful-dnd@13.1.1: react-beautiful-dnd@13.1.1:
resolution: {integrity: sha512-0Lvs4tq2VcrEjEgDXHjT98r+63drkKEgqyxdA7qD3mvKwga6a5SscbdLPO2IExotU1jW8L0Ksdl0Cj2AF67nPQ==} resolution: {integrity: sha512-0Lvs4tq2VcrEjEgDXHjT98r+63drkKEgqyxdA7qD3mvKwga6a5SscbdLPO2IExotU1jW8L0Ksdl0Cj2AF67nPQ==}
deprecated: 'react-beautiful-dnd is now deprecated. Context and options: https://github.com/atlassian/react-beautiful-dnd/issues/2672'
peerDependencies: peerDependencies:
react: ^16.8.5 || ^17.0.0 || ^18.0.0 react: ^16.8.5 || ^17.0.0 || ^18.0.0
react-dom: ^16.8.5 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.5 || ^17.0.0 || ^18.0.0
@ -20325,6 +20332,8 @@ snapshots:
eastasianwidth@0.2.0: {} eastasianwidth@0.2.0: {}
easy-currency-symbol@1.0.1: {}
ecdsa-sig-formatter@1.0.11: ecdsa-sig-formatter@1.0.11:
dependencies: dependencies:
safe-buffer: 5.2.1 safe-buffer: 5.2.1

View File

@ -42,6 +42,7 @@
"dayjs": "^1.11.9", "dayjs": "^1.11.9",
"detect-browser": "^5.3.0", "detect-browser": "^5.3.0",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"easy-currency-symbol": "^1.0.1",
"express": "^4.18.2", "express": "^4.18.2",
"express-async-errors": "^3.1.1", "express-async-errors": "^3.1.1",
"express-validator": "^7.0.1", "express-validator": "^7.0.1",

View File

@ -8,6 +8,7 @@ import { tencentCloudAlarmSchema } from '../../../model/_schema/feed.js';
import { logger } from '../../../utils/logger.js'; import { logger } from '../../../utils/logger.js';
import { compact, fromPairs, get, map, uniqueId } from 'lodash-es'; import { compact, fromPairs, get, map, uniqueId } from 'lodash-es';
import { subscribeEventBus } from '../../../ws/shared.js'; import { subscribeEventBus } from '../../../ws/shared.js';
import { currencyToSymbol } from 'easy-currency-symbol';
export const feedIntegrationRouter = router({ export const feedIntegrationRouter = router({
playground: publicProcedure playground: publicProcedure
@ -232,7 +233,7 @@ export const feedIntegrationRouter = router({
await createFeedEvent(workspaceId, { await createFeedEvent(workspaceId, {
channelId: channelId, channelId: channelId,
eventName: type, eventName: type,
eventContent: `You receive a payment of ${currency} **${amount}**`, eventContent: `You receive a payment of ${currencyToSymbol(currency)}**${amount}**`,
tags: [], tags: [],
source: 'stripe', source: 'stripe',
senderId: eventId, senderId: eventId,
@ -252,7 +253,7 @@ export const feedIntegrationRouter = router({
await createFeedEvent(workspaceId, { await createFeedEvent(workspaceId, {
channelId: channelId, channelId: channelId,
eventName: type, eventName: type,
eventContent: `A payment has been canceled of ${currency} **${amount}**`, eventContent: `A payment has been canceled of ${currencyToSymbol(currency)}**${amount}**`,
tags: [], tags: [],
source: 'stripe', source: 'stripe',
senderId: eventId, senderId: eventId,