feat: native image appending for remote private notes

This commit is contained in:
Julian Lam
2025-11-20 14:08:12 -05:00
parent 6cd8a7c740
commit 822f4edc4c
2 changed files with 14 additions and 1 deletions

View File

@@ -411,7 +411,10 @@ Mocks.message = async (object) => {
mid: object.id,
uid: object.attributedTo,
content: object.sourceContent || object.content,
// ip: caller.ip,
_activitypub: {
attachment: object.attachment,
},
};
return message;

View File

@@ -339,6 +339,16 @@ Notes.assertPrivate = async (object) => {
const payload = await activitypub.mocks.message(object);
// Naive image appending (using src/posts/attachments.js is likely better, but not worth the effort)
if (payload._activitypub.hasOwnProperty('attachment')) {
const images = payload._activitypub.attachment.filter((attachment) => {
return attachment.mediaType.startsWith('image/');
}).map(({ url, href }) => url || href);
images.forEach((url) => {
payload.content += `<p><img class="img-fluid img-thumbnail" src="${url}" /></p>`;
});
}
try {
await messaging.checkContent(payload.content, false);
} catch (e) {