From 3af223cd8e0f7347526b894490d3e3cd496872da Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Tue, 19 Oct 2021 00:04:58 -0400 Subject: [PATCH] :bug: Fix pagination issue with Slack node (#2328) * :zap: Fix pagination in Slack-Node Previously, if you had more than 1k channels, only the first 1k would be loaded. Now with pagination, the limit is ~40k (due to rate limiting, which this doesn't handle well) * :bug: Fix issue with pagination Continues with #2308 Co-authored-by: Fahrzin Hemmati --- packages/nodes-base/nodes/Slack/GenericFunctions.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/nodes-base/nodes/Slack/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/GenericFunctions.ts index 033c87dfef..eb5306de6b 100644 --- a/packages/nodes-base/nodes/Slack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/GenericFunctions.ts @@ -71,15 +71,21 @@ export async function slackApiRequestAllItems(this: IExecuteFunctions | ILoadOpt const returnData: IDataObject[] = []; let responseData; query.page = 1; - query.count = 100; + //if the endpoint uses legacy pagination use count + //https://api.slack.com/docs/pagination#classic + if (endpoint.includes('files.list')) { + query.count = 100; + } else { + query.limit = 5; + } do { responseData = await slackApiRequest.call(this, method, endpoint, body, query); - query.cursor = encodeURIComponent(_.get(responseData, 'response_metadata.next_cursor')); + query.cursor = _.get(responseData, 'response_metadata.next_cursor'); query.page++; returnData.push.apply(returnData, responseData[propertyName]); } while ( (responseData.response_metadata !== undefined && - responseData.response_metadata.mext_cursor !== undefined && + responseData.response_metadata.next_cursor !== undefined && responseData.response_metadata.next_cursor !== '' && responseData.response_metadata.next_cursor !== null) || (responseData.paging !== undefined &&