Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow sending scheduled messages through the slack API
  • Loading branch information
Insanfly authored and fabpot committed Oct 1, 2023
commit a3a7d7afa4e6923b9c5acc37bd510405bc002e09
10 changes: 10 additions & 0 deletions src/Symfony/Component/Notifier/Bridge/Slack/SlackOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ public function asUser(bool $bool): static
return $this;
}

/**
* @return $this
*/
public function postAt(\DateTime $timestamp): static
{
$this->options['post_at'] = $timestamp->getTimestamp();

return $this;
}

/**
* @return $this
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ protected function doSend(MessageInterface $message): SlackSentMessage
$options['text'] = $message->getSubject();

$apiMethod = $message->getOptions() instanceof UpdateMessageSlackOptions ? 'chat.update' : 'chat.postMessage';
if (\array_key_exists('post_at', $options)) {
$apiMethod = 'chat.scheduleMessage';
}

$response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/api/'.$apiMethod, [
'json' => array_filter($options),
'auth_bearer' => $this->accessToken,
Expand Down