jolicode / slack-php-api

:hash: PHP Slack Client based on the official OpenAPI specification
https://jolicode.github.io/slack-php-api/
MIT License
224 stars 56 forks source link

How to properly upgrade `as_user` in v3? #91

Closed jkudish closed 3 years ago

jkudish commented 4 years ago

Hey there!

Glad to see this package being worked on and some updates in v3. Thanks for the contributions 👍

I'm confused about the change to as_user:

I don't follow the change or understand why it was changed. I tried to search for any meaningful commit about this in the repo but didn't see anything relevant either. Can you please explain the change and explain what I should be passing into it to keep the previous behaviour the same (I was previously passing in as_user => true to send DMs on behalf of users)? Is it now expecting the string 'true'?

Thanks so much!

jkudish commented 4 years ago

Hey @damienalexandre sorry to ping you directly but was wondering if you could chime in here?

damienalexandre commented 4 years ago

Hi @jkudish thanks for reporting this issue.

It's highly possible that Slack just broke the specification for no reason.

As I can see in https://raw.githubusercontent.com/slackapi/slack-api-specs/master/web-api/slack_web_openapi_v2_without_examples.json here is all the usages of as_user:

Specified as a boolean in

Specified as a string in

But that's just type hint, in fact boolean in the Slack API can be send as string (everything is a string in HTTP) so using as_user => 'true' should work, have you tried?

I will keep this issue open because that's something we can patch if it's an issue.

jkudish commented 3 years ago

Hi @damienalexandre

Sorry for the delay, some work and life stuff came up and I didn't have a chance to circle back to this until now.

Although I do see that it still says string on the json file you linked to, it does say it should be a boolean on the slack documentation website: https://api.slack.com/methods/chat.postMessage#arg_as_user I believe the documentation in their json is wrong, perhaps it would be worth reaching out to slack support about updating it?

damienalexandre commented 3 years ago

I think the best course of action here is to add a new patch on our end, to transform the "as_user" typed in "string" as "boolean".

Will have a look at this tonight. Cheers

damienalexandre commented 3 years ago

This should be fixed in 3.0.2! Feel free to reopen the issue if you still have any issue.

jkudish commented 3 years ago

Thanks @damienalexandre