mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-24 22:46:41 +07:00
added safeJson function to safely stringify data
This commit is contained in:
parent
1969b2666a
commit
c1fb45742e
3 changed files with 8 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
|||
"remark-frontmatter": "^3.0.0",
|
||||
"remark-parse-frontmatter": "^1.0.3",
|
||||
"retext": "^7.0.1",
|
||||
"safe-json-stringify": "^1.2.0",
|
||||
"socks-proxy-agent": "^5.0.0",
|
||||
"strip-markdown": "^4.0.0",
|
||||
"telegraf": "^4.3.0",
|
||||
|
|
|
@ -6,6 +6,7 @@ import { Template } from "../../template";
|
|||
import { Storage } from "../../db";
|
||||
import { Event } from "../../db/postgres/entities/Event";
|
||||
import logger from "../../logger";
|
||||
import safeJson from "safe-json-stringify";
|
||||
|
||||
export class VkEventHandler<
|
||||
F extends Record<string, any> = any,
|
||||
|
@ -105,7 +106,7 @@ export class VkEventHandler<
|
|||
let plain = "";
|
||||
|
||||
try {
|
||||
plain = JSON.stringify(text);
|
||||
plain = safeJson(text);
|
||||
} catch (e) {
|
||||
logger.warn(`createEvent: failed to stringify JSON: ${e}`, e);
|
||||
plain = text.toString();
|
||||
|
|
|
@ -1531,6 +1531,11 @@ safe-compare@^1.1.4:
|
|||
dependencies:
|
||||
buffer-alloc "^1.2.0"
|
||||
|
||||
safe-json-stringify@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/safe-json-stringify/-/safe-json-stringify-1.2.0.tgz#356e44bc98f1f93ce45df14bcd7c01cda86e0afd"
|
||||
integrity sha512-gH8eh2nZudPQO6TytOvbxnuhYBOvDBBLW52tz5q6X58lJcd/tkmqFR+5Z9adS8aJtURSXWThWy/xJtJwixErvg==
|
||||
|
||||
"safer-buffer@>= 2.1.2 < 3":
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue