mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: integrate post uploads into attachments for outgoing note mocks
This commit is contained in:
@@ -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 = {
|
||||||
|
|||||||
Reference in New Issue
Block a user