From 2812dc2ab107b61dd0dc7f3404ad545ad7062755 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 29 Aug 2021 16:31:32 +0200 Subject: [PATCH] Update ProfilePosts.js --- Network/Queries/ProfilePosts.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Network/Queries/ProfilePosts.js b/Network/Queries/ProfilePosts.js index b24381946..e74d7e81b 100644 --- a/Network/Queries/ProfilePosts.js +++ b/Network/Queries/ProfilePosts.js @@ -45,6 +45,13 @@ exports.newProfilePosts = function newProfilePosts() { throw ('Target Bot Profile Not Found.') } } + + if (queryReceived.targetBotProfileHandle !== undefined) { + thisObject.profile = thisObject.profile.bots.get(queryReceived.targetBotProfileHandle) + if (thisObject.profile === undefined) { + throw ('Target Bot Profile Not Found.') + } + } /* Validate Initial Index */ @@ -102,16 +109,18 @@ exports.newProfilePosts = function newProfilePosts() { let response = [] switch (thisObject.direction) { case DIRECTION_FUTURE: { + let array = Array.from(thisObject.profile.posts) for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { - let arrayItem = thisObject.profile.arrays.posts[i] + let arrayItem = array[i] if (arrayItem === undefined) { break } addToResponse(arrayItem) } break } case DIRECTION_PAST: { + let array = Array.from(thisObject.profile.posts) for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { - let arrayItem = thisObject.profile.arrays.posts[i] + let arrayItem = array[i] if (arrayItem === undefined) { break } addToResponse(arrayItem) } @@ -124,11 +133,13 @@ exports.newProfilePosts = function newProfilePosts() { let postResponse = { emitterUserProfileId: post.emitterUserProfileId, targetUserProfileId: post.targetUserProfileId, + emitterBotProfileId: post.emitterBotProfileId, + targetBotProfileId: post.targetBotProfileId, emitterPostHash: post.emitterPostHash, targetPostHash: post.targetPostHash, postType: post.postType, timestamp: post.timestamp, - repliesCount: post.replies.length, + repliesCount: post.replies.size, reactions: Array.from(post.reactions) } response.push(postResponse)