feat: integrate post uploads into attachments for outgoing note mocks

This commit is contained in:
Julian Lam
2024-04-12 14:08:28 -04:00
parent bb4e418dde
commit fdbd30dc23

View File

@@ -282,7 +282,14 @@ 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 }) => { const uploads = await posts.uploads.listWithSizes(post.pid);
uploads.forEach(({ name, width, height }) => {
const mediaType = mime.getType(name);
const url = `${nconf.get('upload_url')}/${name}`;
attachment.push({ mediaType, url, width, height });
});
attachment = attachment.map(({ mediaType, url, width, height }) => {
let type; let type;
switch (true) { switch (true) {
@@ -297,11 +304,14 @@ Mocks.note = async (post) => {
} }
} }
return { const payload = { type, mediaType, url };
type,
mediaType, if (width || height) {
url, payload.width = width;
}; payload.height = height;
}
return payload;
}); });
const object = { const object = {