From e3c378cbf1d502263c61d3b9c31cd270bc3ae239 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 13 Jan 2023 10:28:31 +0300 Subject: vnext: Telegram bot (WIP) --- vnext/server/common/MessageUtils.js | 16 ++++++++++++++++ vnext/server/common/MessageUtils.spec.js | 2 +- .../common/__snapshots__/MessageUtils.spec.js.snap | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'vnext/server/common') diff --git a/vnext/server/common/MessageUtils.js b/vnext/server/common/MessageUtils.js index f766faf2..74638c02 100644 --- a/vnext/server/common/MessageUtils.js +++ b/vnext/server/common/MessageUtils.js @@ -1,3 +1,5 @@ +import config from 'config'; + /** * check if message is PM * @@ -64,3 +66,17 @@ export function formatQuote(msg) { export function formatMessage(msg) { return msg.body || 'Sent an image'; } + +const baseURL = 'https://juick.com'; + +/** + * @param {import('../api').Message} msg message + */ +export function formatUrl(msg) { + if (isReply(msg)) { + return `${baseURL}/m/${msg.mid}#${msg.rid}`; + } else if (isPM(msg)) { + return `${baseURL}/pm/inbox`; + } + return `${baseURL}/m/${msg.mid}`; +} diff --git a/vnext/server/common/MessageUtils.spec.js b/vnext/server/common/MessageUtils.spec.js index 766b1882..5e6f64c2 100644 --- a/vnext/server/common/MessageUtils.spec.js +++ b/vnext/server/common/MessageUtils.spec.js @@ -27,7 +27,7 @@ describe('Message formatting', () => { 'uname': 'ugnich' }, 'replyQuote': '> The message', - 'body': 'The reply' + 'body': 'The #reply #bla' }; expect(formatTitle(msg)).toMatchSnapshot(); expect(formatQuote(msg)).toMatchSnapshot(); diff --git a/vnext/server/common/__snapshots__/MessageUtils.spec.js.snap b/vnext/server/common/__snapshots__/MessageUtils.spec.js.snap index ea58aebc..fb3c3513 100644 --- a/vnext/server/common/__snapshots__/MessageUtils.spec.js.snap +++ b/vnext/server/common/__snapshots__/MessageUtils.spec.js.snap @@ -14,4 +14,4 @@ exports[`Message formatting Reply message 1`] = `"Reply by ugnich:"`; exports[`Message formatting Reply message 2`] = `"> The message"`; -exports[`Message formatting Reply message 3`] = `"The reply"`; +exports[`Message formatting Reply message 3`] = `"The #reply #bla"`; -- cgit v1.2.3