From 44c2eefb2d4bc2c0f32432ec133e5cbaedb345f9 Mon Sep 17 00:00:00 2001 From: M Gilang Januar Date: Mon, 6 Dec 2021 21:03:10 +0700 Subject: [PATCH] fix get className in message action --- server/package.json | 2 +- server/src/api/v1/Messages.ts | 4 +++- server/src/index.ts | 13 +++++++++++++ yarn.lock | 8 ++++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/server/package.json b/server/package.json index a8d2c5f71..fb4900332 100644 --- a/server/package.json +++ b/server/package.json @@ -9,7 +9,7 @@ "build": "rimraf dist && eslint --fix -c .eslintrc.js --ext .ts . && tsc" }, "dependencies": { - "@mgilangjanuar/telegram": "2.0.4", + "@mgilangjanuar/telegram": "2.0.9", "@sentry/node": "^6.14.1", "@sentry/tracing": "^6.14.1", "@types/moment": "^2.13.0", diff --git a/server/src/api/v1/Messages.ts b/server/src/api/v1/Messages.ts index 2a616e71e..f99f9d935 100644 --- a/server/src/api/v1/Messages.ts +++ b/server/src/api/v1/Messages.ts @@ -32,7 +32,9 @@ export class Messages { limit: Number(limit) || 0, offsetId: Number(offset) || 0, })) - return res.send({ messages }) + const result = JSON.parse(JSON.stringify(messages)) + result.messages = result.messages?.map((msg, i) => ({ ...msg, action: { ...msg.action, className: messages['messages'][i]?.action?.className } })) + return res.send({ messages: result }) } @Endpoint.POST('/read/:type/:id', { middlewares: [Auth] }) diff --git a/server/src/index.ts b/server/src/index.ts index 88350bafe..840216703 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -36,6 +36,19 @@ import { runDB } from './model' // } // } +// const stringify = JSON.stringify +// JSON.stringify = str => { +// if (!str) return str +// try { +// const res = bigInt({ storeAsString: true }).stringify(str) +// return stringify(JSON.stringify(res)) +// } catch (error) { +// console.error('FATAL JSON.stringify:', str) +// return stringify(str) +// } +// } + + runDB() const app = express() diff --git a/yarn.lock b/yarn.lock index 5eb85b1a8..6146b9816 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1544,10 +1544,10 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" -"@mgilangjanuar/telegram@2.0.4": - version "2.0.4" - resolved "https://npm.pkg.github.com/download/@mgilangjanuar/telegram/2.0.4/d17208e5ff0f9107bfdb485f88d235bedd57e3f37783e89d58889de59939f765#6049e301672092b3d7b9d8807e22fbac566ee0d2" - integrity sha512-3Uf0N4PAUoBX286BohyZ0g5yLJp+LQlhBij0K68eZPT6R/XUV1PjXU+/WsVSehYjx6Kk6yeU8oiuyOVQ8mS8NQ== +"@mgilangjanuar/telegram@2.0.9": + version "2.0.9" + resolved "https://npm.pkg.github.com/download/@mgilangjanuar/telegram/2.0.9/7de66d2ca37cf1bed8f889157d8e6c07cc53fc6477a2cfcf6e68ee7c839c0514#0087d944d7d1ed8bd4db9e580d43148d8580a7f0" + integrity sha512-COHrncMWDFdmUhWQUAODs7AtcSPw9ngMXzULdmf9cYlxDrX+mOh8boyl2js/nIdRl2U2hKxq9HwmVz13DBDovw== dependencies: "@cryptography/aes" "^0.1.1" async-mutex "^0.3.0"