Skip to content
New issue

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

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

Already on GitHub? # to your account

Added metadata definition for chat.postMessage and history #156

Merged
merged 6 commits into from
Nov 10, 2023

Conversation

tchapuis
Copy link
Contributor

The Slack documentation says that we can include metadata in chat.postMessage arguments. See : https://api.slack.com/metadata

OpenApi spec for this argument doesn't seem to be up to date.

So I added it to the patched version for message definition and chat.postMessage method. I also added the include_all_metadata argument for the conversations.history method

@yngc0der
Copy link

The temporary solution is create a custom endpoint class, and use this class to call api method:

<?php

use JoliCode\Slack\Api\Endpoint\ChatPostMessage;

final class FixedChatPostMessageEndpoint extends ChatPostMessage
{
    protected function getFormOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
    {
        $optionsResolver = parent::getFormOptionsResolver();
        $optionsResolver->setDefined(['metadata']);
        $optionsResolver->setAllowedTypes('metadata', ['string']);
        return $optionsResolver;
    }
}


$slack->executeEndpoint(new FixedChatPostMessageEndpoint([
    'channel' => $channel,
    'text' => $text,
    'metadata' => $metadata,
]));

Copy link
Member

@damienalexandre damienalexandre left a comment

Choose a reason for hiding this comment

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

Hello, sorry for the very long delay on the review.

I fear the ".patch" file is wrong, it includes A LOT of changes that have nothing to do with the metadata definition 🤔 Maybe it's just because Slack updated their definition, but we should then split this in two PR.

Thank you for your understanding 🙏

resources/slack-openapi-sorted.patch Outdated Show resolved Hide resolved
@tchapuis
Copy link
Contributor Author

Hello,
The patch file was a pain to get it right 😅

@damienalexandre
Copy link
Member

Thanks for working on this!

Tests on main were red, so I fixed them in #162 ;
could you please:

  • rm -rf generated/
  • vendor/bin/jane-openapi generate --config-file=.jane-openapi.php

And push?

@damienalexandre damienalexandre merged commit 9b923e4 into jolicode:main Nov 10, 2023
@damienalexandre
Copy link
Member

Awesome, thank you so much!

@damienalexandre
Copy link
Member

Version v4.6.0 is published!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants