aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/common
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-13 10:28:31 +0300
committerGravatar Vitaly Takmazov2023-01-14 10:06:45 +0300
commite3c378cbf1d502263c61d3b9c31cd270bc3ae239 (patch)
tree9e038f42349671407e6f5906681de6448565f8eb /vnext/server/common
parentd94eec89b104e5c839d76c74ce94e83960d49c31 (diff)
vnext: Telegram bot (WIP)
Diffstat (limited to 'vnext/server/common')
-rw-r--r--vnext/server/common/MessageUtils.js16
-rw-r--r--vnext/server/common/MessageUtils.spec.js2
-rw-r--r--vnext/server/common/__snapshots__/MessageUtils.spec.js.snap2
3 files changed, 18 insertions, 2 deletions
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"`;