mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-19 23:10:21 +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) || [];
|
let attachment = await posts.attachments.get(post.pid) || [];
|
||||||
attachment = attachment.map(({ mediaType, url }) => ({
|
attachment = attachment.map(({ mediaType, url }) => {
|
||||||
type: 'Document',
|
let type;
|
||||||
mediaType,
|
|
||||||
url,
|
switch (true) {
|
||||||
}));
|
case mediaType.startsWith('image'): {
|
||||||
|
type = 'Image';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
type = 'Link';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type,
|
||||||
|
mediaType,
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const object = {
|
const object = {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
|||||||
Reference in New Issue
Block a user