Skip to content

Node.js based forum software built for the modern web

fix: call relativeToAbsolute helper when generating markdown source content in mocks.notes.public/private

Julian Lam02fb99ebb6cc
diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.js
index 35fd9eb75d..da0416fde0 100644
--- a/src/activitypub/helpers.js
+++ b/src/activitypub/helpers.js
@@ -35,7 +35,7 @@ Helpers._test = (method, args) => {
}, 2500);
};
// process.nextTick(() => {
-// Helpers._test(activitypub.notes.assert, [1, `https://`]);
+// Helpers._test(activitypub.notes.assert, [1, `https://`]);
// });
let _lastLog;
diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js
index 67c6636bc4..842c3b3d21 100644
--- a/src/activitypub/mocks.js
+++ b/src/activitypub/mocks.js
@@ -453,7 +453,8 @@ Mocks.notes.public = async (post) => {
const _post = { ...post };
const raw = await posts.getPostField(post.pid, 'content');
_post.content = raw;
- const { content } = await posts.parsePost(_post, 'markdown');
+ let { content } = await posts.parsePost(_post, 'markdown');
+ content = posts.relativeToAbsolute(content, posts.mdImageUrlRegex);
source = {
content,
mediaType: 'text/markdown',
@@ -500,7 +501,7 @@ Mocks.notes.public = async (post) => {
});
// Inspect post content for external imagery as well
- let match = posts.imgRegex.regex.exec(post.content);
+ let match = posts.imgRegex.exec(post.content);
while (match !== null) {
if (match[1]) {
const { hostname, pathname, href: url } = new URL(match[1]);
@@ -509,7 +510,7 @@ Mocks.notes.public = async (post) => {
attachment.push({ mediaType, url });
}
}
- match = posts.imgRegex.regex.exec(post.content);
+ match = posts.imgRegex.exec(post.content);
}
attachment = attachment.map(({ mediaType, url, width, height }) => {
@@ -600,8 +601,11 @@ Mocks.notes.private = async ({ messageObj }) => {
let source;
const markdownEnabled = await plugins.isActive('nodebb-plugin-markdown');
if (markdownEnabled) {
+ let { content } = messageObj;
+ content = posts.relativeToAbsolute(content, posts.mdImageUrlRegex);
+
source = {
- content: messageObj.content,
+ content,
mediaType: 'text/markdown',
};
}