Skip to content

Commit

Permalink
Merge pull request #588 from seratch/issue-586
Browse files Browse the repository at this point in the history
Fix #586 hubot-slack calling bots.info a suspicious number of times
  • Loading branch information
seratch authored Apr 3, 2020
2 parents 933bafc + f6b3e7f commit 3767644
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class SlackClient
return Promise.resolve(@botUserIdMap[botId]) if @botUserIdMap[botId]?

# Bot user is not in mapping - call bots.info
@robot.logger.debug "SlackClient#fetchBotUser() Calling bots.info API for bot_id: #{botId}"
@web.bots.info(bot: botId).then((r) => r.bot)

###*
Expand Down Expand Up @@ -331,9 +332,13 @@ class SlackClient
if @eventHandler
# fetch full representations of the user, bot, and potentially the item_user.
fetches = {}
fetches.user = @fetchUser event.user if event.user
fetches.bot = @fetchBotUser event.bot_id if event.bot_id
fetches.item_user = @fetchUser event.item_user if event.item_user
if event.bot_id
fetches.bot = @fetchBotUser event.bot_id
else if event.user
fetches.user = @fetchUser event.user

if event.item_user
fetches.item_user = @fetchUser event.item_user

# after fetches complete...
Promise.props(fetches)
Expand Down

0 comments on commit 3767644

Please sign in to comment.