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

Added Blocks support, as well as adjusted for new SearchSort enums returned by the Slack LoginResponse model #178

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

PeterJFerrarotto
Copy link

Added support for Blocks to all API methods, and also accounted for two new enum values (not_set, relevant) for SearchSort from the Slack LoginResponse -> Self -> Preferences model. (Relevant seems to be solely used for search_channel_sort and search_people_sort [two new SearchSort values in the response that I also accounted for], but it's possible it could be set to that for the overall search_sort as well.)

@Inumedia
Copy link
Owner

Inumedia commented Apr 30, 2019

There's already support about to be added for Blocks by @clockworkcoding @ #172

SlackAPI/RPCMessages/SearchResponseMessages.cs Outdated Show resolved Hide resolved
SlackAPI/Preferences.cs Outdated Show resolved Hide resolved
@@ -0,0 +1,501 @@
namespace SlackAPI
Copy link
Owner

Choose a reason for hiding this comment

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

This whole file has wrong indentation (should be 4 spaces)

Copy link
Owner

Choose a reason for hiding this comment

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

While I do like the more polymorphic approach to the Block support, it seems quite a bit more complex.

@clockworkcoding do you think this is worthwhile to merge in instead of your simpler implementation?

My biggest complaint against this one is that it seems considerably more complex

Copy link
Author

Choose a reason for hiding this comment

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

It definitely is more complex - the main reason I developed it with this is that I wanted to be able to dynamically generate the message without having to memorize what fields each block or element type has. This was actually originally an addition to the slack-api-csharp library that implements Events, as I built a SlackBot that uses JSON templates to dynamically build block messages and dialogs with data from a SQL server upon user request. (Hence the necessity for polymorphism, so I don't have to check a billion things whenever I try to parse the template.)

And I'm using this library in a VB.NET winforms application at my job (I didn't choose the language, the application is already very expansive and we plan to move it to a web-based platform), so whenever I get a chance to work with ACTUAL object-oriented stuff, I really go for it.

Copy link
Author

Choose a reason for hiding this comment

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

So, yeah - very niche use case, and if new block and/or element types are added, this code would need to be adjusted to account for that. There is probably a simpler way to do it that would enable dynamic generation of block-based messages, but I very much wanted to keep them distinct (also, SlackTexts can be used in Field for Section Blocks, which also takes Image, so that added another layer of complexity.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I went with a simple approach for two reasons:

  1. To keep consistent with the rest of the api
  2. To allow consumers to use new element types that reuse the same fields without waiting for this api to update.
    I like the ease of use this approach provides, but the lack of consistency might be an issue, until or unless we want to provide a similar interface throughout.

Copy link
Owner

Choose a reason for hiding this comment

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

Personally I like this approach, but yeah it breaks apart from the convention of the rest of the library.

Again, personally, it's been on my mind for a while that the whole library needs to be overhauled to follow a simpler approach (re: ease-of-use) to hopefully prevent some of the issues I've been seeing of people having trouble with using the library in general. To be quite honest, I wrote this whole library initially when I was still very much a novice at C# and added in too many features that most people probably don't know about / I don't even remember at this point. I wonder if there's a nice medium we could find that allows adding new features (without waiting for library updates) and is easier to use.

@gpailler , sorry to drag you in, but I'd like your opinion on this.

SlackAPI/SlackClient.cs Outdated Show resolved Hide resolved
SlackAPI/SlackClient.cs Outdated Show resolved Hide resolved
SlackAPI/SlackTaskClient.cs Outdated Show resolved Hide resolved
SlackAPI/Block.cs Outdated Show resolved Hide resolved
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.

3 participants