From 8240dbad7d16be6a04d0b7cd0033ce46122b8571 Mon Sep 17 00:00:00 2001 From: kintarowins Date: Fri, 4 Dec 2020 15:40:54 -0800 Subject: [PATCH 1/6] make PAGE_SIZE configurable --- slack.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/slack.coffee b/slack.coffee index c13a17cf..a2175137 100644 --- a/slack.coffee +++ b/slack.coffee @@ -5,6 +5,7 @@ exports.use = (robot) -> options = token: process.env.HUBOT_SLACK_TOKEN disableUserSync: process.env.DISABLE_USER_SYNC? + apiPageSize: process.env.API_PAGE_SIZE # reacts to only messages by insalled workspace users in a shared channel installedTeamOnly: process.env.INSTALLED_TEAM_ONLY? try From 1c260ce28e136aa76abf6de8ef24439943b757de Mon Sep 17 00:00:00 2001 From: kintarowins Date: Fri, 4 Dec 2020 15:43:41 -0800 Subject: [PATCH 2/6] Make PAGE_SIZE configurable --- src/bot.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bot.coffee b/src/bot.coffee index e3a47c5d..746ac3f0 100644 --- a/src/bot.coffee +++ b/src/bot.coffee @@ -13,6 +13,7 @@ class SlackBot extends Adapter # @param {Object} options - configuration options for the adapter # @param {string} options.token - authentication token for Slack APIs # @param {Boolean} options.disableUserSync - disables syncing all user data on start + # @param {string} options.apiPageSize - sets Slack API page size # @param {Boolean} options.installedTeamOnly - reacts to only messages by insalled workspace users in a shared channel # @param {Object} options.rtm - RTM configuration options for SlackClient # @param {Object} options.rtmStart - options for `rtm.start` Web API method From e7ad726f7ecaa7d713836c6d5521aff2d19d5e65 Mon Sep 17 00:00:00 2001 From: kintarowins Date: Fri, 4 Dec 2020 15:45:13 -0800 Subject: [PATCH 3/6] Make PAGE_SIZE configurable --- src/client.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/client.coffee b/src/client.coffee index 98e27ab2..78a9bdb5 100644 --- a/src/client.coffee +++ b/src/client.coffee @@ -28,6 +28,7 @@ class SlackClient # @constructor # @param {Object} options - Configuration options for this SlackClient instance # @param {string} options.token - Slack API token for authentication + # @param {string} options.apiPageSize - Slack API page size # @param {Object} [options.rtm={}] - Configuration options for owned RtmClient instance # @param {Object} [options.rtmStart={}] - Configuration options for RtmClient#start() method # @param {boolean} [options.noRawText=false] - Deprecated: All SlackTextMessages (subtype of TextMessage) will contain @@ -43,6 +44,9 @@ class SlackClient @rtm = new RtmClient options.token, options.rtm @web = new WebClient options.token, { maxRequestConcurrency: 1 } + unless isNaN(options.apiPageSize) + SlackClient.PAGE_SIZE = parseInt(options.apiPageSize, 10) + @robot.logger.debug "RtmClient initialized with options: #{JSON.stringify(options.rtm)}" @rtmStartOpts = options.rtmStart || {} From f385f425b4ee86341a452d8d6c0ef39a5d86711b Mon Sep 17 00:00:00 2001 From: kintarowins Date: Mon, 7 Dec 2020 19:32:59 -0800 Subject: [PATCH 4/6] change constant to instance variable --- src/client.coffee | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/client.coffee b/src/client.coffee index 78a9bdb5..5e6464bc 100644 --- a/src/client.coffee +++ b/src/client.coffee @@ -4,12 +4,6 @@ Promise = require "bluebird" SlackFormatter = require "./formatter" class SlackClient - ###* - # Number used for limit when making paginated requests to Slack Web API list methods - # @private - ### - @PAGE_SIZE = 100 - ###* # Number of milliseconds which the information returned by `conversations.info` is considered to be valid. The default # value is 5 minutes, and it can be customized by setting the `HUBOT_SLACK_CONVERSATION_CACHE_TTL_MS` environment @@ -28,7 +22,7 @@ class SlackClient # @constructor # @param {Object} options - Configuration options for this SlackClient instance # @param {string} options.token - Slack API token for authentication - # @param {string} options.apiPageSize - Slack API page size + # @param {string} options.apiPageSize - Number used for limit when making paginated requests to Slack Web API list methods # @param {Object} [options.rtm={}] - Configuration options for owned RtmClient instance # @param {Object} [options.rtmStart={}] - Configuration options for RtmClient#start() method # @param {boolean} [options.noRawText=false] - Deprecated: All SlackTextMessages (subtype of TextMessage) will contain @@ -43,9 +37,10 @@ class SlackClient # this object's API. The property is no longer used internally. @rtm = new RtmClient options.token, options.rtm @web = new WebClient options.token, { maxRequestConcurrency: 1 } - + + @apiPageSize = 100 unless isNaN(options.apiPageSize) - SlackClient.PAGE_SIZE = parseInt(options.apiPageSize, 10) + @apiPageSize = parseInt(options.apiPageSize, 10) @robot.logger.debug "RtmClient initialized with options: #{JSON.stringify(options.rtm)}" @rtmStartOpts = options.rtmStart || {} @@ -221,13 +216,13 @@ class SlackClient if results?.response_metadata?.next_cursor # fetch next page @web.users.list({ - limit: SlackClient.PAGE_SIZE, + limit: @apiPageSize, cursor: results.response_metadata.next_cursor }, pageLoaded) else # pagination complete, run callback with results callback(null, combinedResults) - @web.users.list({ limit: SlackClient.PAGE_SIZE }, pageLoaded) + @web.users.list({ limit: @apiPageSize }, pageLoaded) ###* # Fetch user info from the brain. If not available, call users.info From a9c073e05ed9c8f47ed56c2a9a44fb9077ac6276 Mon Sep 17 00:00:00 2001 From: kintarowins Date: Fri, 11 Dec 2020 07:24:05 -0800 Subject: [PATCH 5/6] bump default api page size to 200 --- src/client.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.coffee b/src/client.coffee index 5e6464bc..25c77140 100644 --- a/src/client.coffee +++ b/src/client.coffee @@ -38,7 +38,7 @@ class SlackClient @rtm = new RtmClient options.token, options.rtm @web = new WebClient options.token, { maxRequestConcurrency: 1 } - @apiPageSize = 100 + @apiPageSize = 200 unless isNaN(options.apiPageSize) @apiPageSize = parseInt(options.apiPageSize, 10) From 8f1a999165f472660551cf9f4c463a7aca561d8a Mon Sep 17 00:00:00 2001 From: kintarowins Date: Thu, 17 Dec 2020 07:43:08 -0800 Subject: [PATCH 6/6] revert default pagesize bump --- src/client.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.coffee b/src/client.coffee index 25c77140..5e6464bc 100644 --- a/src/client.coffee +++ b/src/client.coffee @@ -38,7 +38,7 @@ class SlackClient @rtm = new RtmClient options.token, options.rtm @web = new WebClient options.token, { maxRequestConcurrency: 1 } - @apiPageSize = 200 + @apiPageSize = 100 unless isNaN(options.apiPageSize) @apiPageSize = parseInt(options.apiPageSize, 10)