Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove SlackDataStore is deprecated warning message #1560

Closed
1 of 7 tasks
ykcab opened this issue Nov 16, 2022 · 3 comments
Closed
1 of 7 tasks

How to remove SlackDataStore is deprecated warning message #1560

ykcab opened this issue Nov 16, 2022 · 3 comments
Labels
auto-triage-stale question M-T: User needs support to use the project

Comments

@ykcab
Copy link

ykcab commented Nov 16, 2022

I am getting the follow error when I start Hubot:

warn: SlackDataStore is deprecated and will be removed in the next major version. See project documentation for a migration guide.
warn: SlackDataStore is deprecated and will be removed in the next major version. See project documentation for a migration guide.

Although it is mentioned here #410, I couldn't locable where to implement the fix within the code

Following this guide https://github.com/slackapi/node-slack-sdk/wiki/DataStore-v3.x-Migration-Guide, search for dataStore yield the following:

module.exports = (robot) ->
  robot.whitelistRooms = (currentRoomId, whitelist) ->
    group = robot.adapter.client.rtm.dataStore.getGroupById(currentRoomId)
    channel = robot.adapter.client.rtm.dataStore.getChannelById(currentRoomId)
    if group
      currentRoom = group.name
    if channel
      currentRoom = channel.name
    _.contains whitelist, currentRoom

From here, I'd like to understand how to actually implement this https://github.com/slackapi/node-slack-sdk/wiki/DataStore-v3.x-Migration-Guide#what-should-i-change-in-my-app-to-prepare-for-v4

Packages:

Select all that apply:

  • @slack/web-api
  • @slack/rtm-api
  • @slack/webhooks
  • @slack/oauth
  • @slack/socket-mode
  • @slack/types
  • I don't know

Reproducible in:

The Slack SDK version

Package.json

{
  "name": "mybot",
  "version": "0.0.0",
  "private": true,
  "author": "",
  "description": "my hubot app",
  "dependencies": {
    "aws-sdk": "^2.7",
    "bufferutil": "^4.0.6",
    "child_process": "^1.0.2",
    "gulp": "^4.0.2",
    "gulp-awspublish": "^6.0.2",
    "hubot": "^3.3.2",
    "hubot-diagnostics": "^1.0.0",
    "hubot-google-images": "^0.2.7",
    "hubot-google-translate": "^0.2.1",
    "hubot-help": "^1.0.1",
    "hubot-heroku-keepalive": "^1.0.3",
    "hubot-maps": "^0.0.3",
    "hubot-pugme": "^0.1.1",
    "hubot-redis-brain": "^1.0.0",
    "hubot-rules": "^1.0.0",
    "hubot-scripts": "^2.17.2",
    "hubot-shipit": "^0.2.1",
    "hubot-slack": "^4.8.0",
    "mkdirp": "^1.0.4",
    "npm": "^8.19.2",
    "request": "^2.88.2",
    "underscore": "^1.13.4",
    "utf-8-validate": "^5.0.9",
    "util": "^0.12.4"
  },
  "engines": {
    "node": "^19.x.x"
  }
}

Node.js runtime version

see package.json

OS info

ubuntu

Expected result:

Remove the warning

@zimeg zimeg added question M-T: User needs support to use the project and removed untriaged labels Nov 17, 2022
@zimeg
Copy link
Member

zimeg commented Nov 17, 2022

Hi @ykcab! To remove the rtm.dataStore and the error it's causing, the code from the migration guide should work with a few changes to mimic your function. Both getGroupById and getChannelById can be replaced by a single call to the conversations.info method and the channel name can be collected from this response object. An implementation of this might look something like so:

{ RtmClient, WebClient } = require('@slack/client');
web = new WebClient('your-token-here');

module.exports = (robot) ->
  robot.whitelistRooms = (currentRoomId, whitelist) ->
    channel = await web.conversations.info(currentRoomId)
      .then(resp => resp.channel)
      .catch(error => console.error("Failed to retrieve channel info: " + error));
    _.contains whitelist, channel

@github-actions
Copy link

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

@github-actions
Copy link

github-actions bot commented Jan 2, 2023

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

@github-actions github-actions bot closed this as completed Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-triage-stale question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

2 participants