mirror of
https://github.com/anatolykopyl/vk-nft-feed.git
synced 2026-03-26 04:44:34 +00:00
30 lines
582 B
JavaScript
30 lines
582 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(...postToImage(post));
|
|
}
|
|
|
|
return images;
|
|
}
|