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

Use conversations_list instead of deprecated channels_list #331

Merged
merged 15 commits into from
Jul 7, 2020

Conversation

wasabigeek
Copy link
Contributor

Fixes #328

TBH I'm not sure if I missed something. The two methods are not like-for-like but conversations_list seems a reasonable drop-in:

  • the default will only return public_channels
  • the objects returned seem to have a similar structure to channels_list, I would assume the default would filter out all the non-channel objects (e.g. IMs)

For comparison:

@dblock
Copy link
Collaborator

dblock commented Jun 29, 2020

I think you're also missing new mixins in https://github.com/slack-ruby/slack-ruby-client/tree/master/lib/slack/web/api/mixins for at least the conversations methods.

@@ -17,7 +17,7 @@ def channels_id(options = {})
throw ArgumentError.new('Required arguments :channel missing') if name.nil?

id_for(:channel, name, '#', :channels, 'channel_not_found') do
channels_list
conversations_list
Copy link
Collaborator

@dblock dblock Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When users call channels_ they get deprecations. I think we want to keep that. For those that call conversations_ we shouldn't have any deprecations. I don't think we should mix both. It's in id_for that we want to call the new(er) methods, therefore calling conversations_history won't show deprecations, which is the issue that was raised.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't quite follow this

It's in id_for that we want to call the new(er) methods

If I understood correctly, the conversations_-methods still use this same channels_id method, which would result in calling the deprecated channels_list method. Did you mean we should have some logic to determine whether channels_list or conversations_list is used, depending on whether it's a channels_ or conversations_ method call?

If so, I could make a copy of this method that uses conversations_list, and in the method templates use deprecated: true as a signal for whether to use this new method instead of channels_id. What do you think?

Copy link
Collaborator

@dblock dblock Jun 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try again. I don't think we should rewrite channels_id, but deprecate it.

  • introduce Mixins::Conversations::Ids#conversations_id that looks just like this method except change channels to conversations
  • deprecate channels_id the usual way with a warning
  • call conversations_id everywhere we call channels_id except in deprecated channels_list method

This way we don't change this mix-in and fix any method that has not been deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, will go with that!

@wasabigeek
Copy link
Contributor Author

wasabigeek commented Jul 3, 2020

@dblock there's a sizable set of changes that are incoming with the updated slack-api-ref, could you take a look at this before I push them? I will try to re-record the VCR for channels_info.yml after.

Aside: ActiveSupport was still required for the rake task, so I re-required it in the file.

@wasabigeek
Copy link
Contributor Author

Hmm on second look the overall impact of this was the same as the previous implementation (swapping out channels_list for conversations_list) as channels_list itself doesn’t use channels_id (well, duh 🤦), so the Channels mixin is essentially unused now. Should I revert to the previous implementation?

@dblock
Copy link
Collaborator

dblock commented Jul 6, 2020

As is this looks good to me (other than the failing build, rubocop), what am I missing? Channels mixin can be left alone, the template change makes sense as it defaults to the newer method now.

@@ -40,7 +40,7 @@ module Slack
<% if data['group'] == 'groups' && data['args']['channel'] && !data['args']['channel']['desc'].include?('Can be an encoded ID, or a name.') %>
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
<% elsif data['args']['channel'] && !data['args']['channel']['desc'].include?('Can be an encoded ID, or a name.') %>
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perfect, fixes the regression in all cases.

@wasabigeek
Copy link
Contributor Author

As is this looks good to me (other than the failing build, rubocop), what am I missing? Channels mixin can be left alone, the template change makes sense as it defaults to the newer method now.

It seemed like the Channels mixin becomes essentially useless, as it's one and only method (channels_id) is no longer called elsewhere in the code (except in bin/commands/channels.rb, I'm not sure what that is for yet), so I thought we may as well get rid of it / repurpose it to use conversations_list - what do you think?

@dblock
Copy link
Collaborator

dblock commented Jul 6, 2020

As is this looks good to me (other than the failing build, rubocop), what am I missing? Channels mixin can be left alone, the template change makes sense as it defaults to the newer method now.

It seemed like the Channels mixin becomes essentially useless, as it's one and only method (channels_id) is no longer called elsewhere in the code (except in bin/commands/channels.rb, I'm not sure what that is for yet), so I thought we may as well get rid of it / repurpose it to use conversations_list - what do you think?

I think someone may be using it directly so we should keep it. We can delete it when the deprecated API is removed I think.

Happy to merge on 🍏

@dblock
Copy link
Collaborator

dblock commented Jul 6, 2020

Not sure what's up with CI.

@dblock dblock merged commit 498f34e into slack-ruby:master Jul 7, 2020
@dblock
Copy link
Collaborator

dblock commented Jul 7, 2020

Amen, merged.

@wasabigeek wasabigeek deleted the fix-channels-id branch July 7, 2020 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Method Deprecated error when using conversations_history
2 participants