mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-16 13:30:23 +01:00
feat: native image appending for remote private notes
This commit is contained in:
@@ -411,7 +411,10 @@ Mocks.message = async (object) => {
|
|||||||
mid: object.id,
|
mid: object.id,
|
||||||
uid: object.attributedTo,
|
uid: object.attributedTo,
|
||||||
content: object.sourceContent || object.content,
|
content: object.sourceContent || object.content,
|
||||||
// ip: caller.ip,
|
|
||||||
|
_activitypub: {
|
||||||
|
attachment: object.attachment,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
|
|||||||
@@ -339,6 +339,16 @@ Notes.assertPrivate = async (object) => {
|
|||||||
|
|
||||||
const payload = await activitypub.mocks.message(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 {
|
try {
|
||||||
await messaging.checkContent(payload.content, false);
|
await messaging.checkContent(payload.content, false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user