Files
vk-nft-feed/getImages.js
2022-01-23 04:22:13 +03:00

30 lines
585 B
JavaScript

import getPosts from './getPosts.js';
import postToImage from './postToImage.js';
function filterPosts(posts) {
return posts.filter((post) => {
let isValid = false;
if (post.attachments) {
post.attachments.forEach((attachment) => {
isValid = isValid || attachment.type === 'photo';
})
}
return isValid;
})
}
export default async function(owner_id) {
let posts = await getPosts(owner_id);
posts = filterPosts(posts);
let images = [];
for (const post of posts) {
images.push(await postToImage(post));
}
return images;
}