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

This commit is contained in:
Julian Lam
2025-01-29 12:03:22 -05:00
parent f64e6f0f1a
commit 02fb99ebb6
2 changed files with 9 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ Helpers._test = (method, args) => {
}, 2500); }, 2500);
}; };
// process.nextTick(() => { // process.nextTick(() => {
// Helpers._test(activitypub.notes.assert, [1, `https://`]); // Helpers._test(activitypub.notes.assert, [1, `https://`]);
// }); // });
let _lastLog; let _lastLog;

View File

@@ -453,7 +453,8 @@ Mocks.notes.public = async (post) => {
const _post = { ...post }; const _post = { ...post };
const raw = await posts.getPostField(post.pid, 'content'); const raw = await posts.getPostField(post.pid, 'content');
_post.content = raw; _post.content = raw;
const { content } = await posts.parsePost(_post, 'markdown'); let { content } = await posts.parsePost(_post, 'markdown');
content = posts.relativeToAbsolute(content, posts.mdImageUrlRegex);
source = { source = {
content, content,
mediaType: 'text/markdown', mediaType: 'text/markdown',
@@ -500,7 +501,7 @@ Mocks.notes.public = async (post) => {
}); });
// Inspect post content for external imagery as well // 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) { while (match !== null) {
if (match[1]) { if (match[1]) {
const { hostname, pathname, href: url } = new URL(match[1]); const { hostname, pathname, href: url } = new URL(match[1]);
@@ -509,7 +510,7 @@ Mocks.notes.public = async (post) => {
attachment.push({ mediaType, url }); attachment.push({ mediaType, url });
} }
} }
match = posts.imgRegex.regex.exec(post.content); match = posts.imgRegex.exec(post.content);
} }
attachment = attachment.map(({ mediaType, url, width, height }) => { attachment = attachment.map(({ mediaType, url, width, height }) => {
@@ -600,8 +601,11 @@ Mocks.notes.private = async ({ messageObj }) => {
let source; let source;
const markdownEnabled = await plugins.isActive('nodebb-plugin-markdown'); const markdownEnabled = await plugins.isActive('nodebb-plugin-markdown');
if (markdownEnabled) { if (markdownEnabled) {
let { content } = messageObj;
content = posts.relativeToAbsolute(content, posts.mdImageUrlRegex);
source = { source = {
content: messageObj.content, content,
mediaType: 'text/markdown', mediaType: 'text/markdown',
}; };
} }