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

Skip to content

Commit e459f34

Browse files
committed
feature #50141 Allow sending scheduled messages through the slack API (Insanfly)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- Allow sending scheduled messages through the slack API | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | / | License | MIT | Doc PR | TODO Add option post_at to the Slack Notifier bridge, this allows for easy scheduling of Slack messages. Commits ------- a3a7d7a Allow sending scheduled messages through the slack API
2 parents 73a3f78 + a3a7d7a commit e459f34

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Symfony/Component/Notifier/Bridge/Slack/SlackOptions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ public function asUser(bool $bool): static
8787
return $this;
8888
}
8989

90+
/**
91+
* @return $this
92+
*/
93+
public function postAt(\DateTime $timestamp): static
94+
{
95+
$this->options['post_at'] = $timestamp->getTimestamp();
96+
97+
return $this;
98+
}
99+
90100
/**
91101
* @return $this
92102
*/

src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ protected function doSend(MessageInterface $message): SlackSentMessage
7676
$options['text'] = $message->getSubject();
7777

7878
$apiMethod = $message->getOptions() instanceof UpdateMessageSlackOptions ? 'chat.update' : 'chat.postMessage';
79+
if (\array_key_exists('post_at', $options)) {
80+
$apiMethod = 'chat.scheduleMessage';
81+
}
82+
7983
$response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/api/'.$apiMethod, [
8084
'json' => array_filter($options),
8185
'auth_bearer' => $this->accessToken,

0 commit comments

Comments
 (0)