mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-16 13:30:23 +01:00
fix: change default attachment type to Link, or Image if mediaType matches
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user