Skip to content

Node.js based forum software built for the modern web

fix: change default attachment type to Link, or Image if mediaType matches

Julian Lambb4e418dde21
diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js
index f9bcad3f2b..f0bca1f134 100644
--- a/src/activitypub/mocks.js
+++ b/src/activitypub/mocks.js
@@ -282,11 +282,27 @@ Mocks.note = async (post) => {
}
let attachment = await posts.attachments.get(post.pid) || [];
- attachment = attachment.map(({ mediaType, url }) => ({
- type: 'Document',
- mediaType,
- url,
- }));
+ attachment = attachment.map(({ mediaType, url }) => {
+ let type;
+
+ switch (true) {
+ case mediaType.startsWith('image'): {
+ type = 'Image';
+ break;
+ }
+
+ default: {
+ type = 'Link';
+ break;
+ }
+ }
+
+ return {
+ type,
+ mediaType,
+ url,
+ };
+ });
const object = {
'@context': 'https://www.w3.org/ns/activitystreams',