Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4: (24 commits)
  Fix Twig tests
  [Scheduler] Fix tests
  [TwigBridge] Add FormLayoutTestCase class
  Fix CS
  Allow sending scheduled messages through the slack API
  [TwigBridge] Add `AppVariable::getEnabledLocales()` to retrieve the enabled locales
  [RateLimiter] Add missing dependency
  [RateLimiter] Add SlidingWindowLimiter::reserve()
  [Messenger] Add WrappedExceptionsInterface for nested exceptions
  [Mime] Add `TemplatedEmail::locale()` to set the locale for the email rendering
  Fix CS
  [Messenger][Scheduler] Add AsCronTask & AsPeriodicTask attributes
  [Scheduler] Make debug:scheduler output more useful
  [Notifier] Tweak some phpdocs
  [FrameworkBundle] Change BrowserKitAssertionsTrait::getClient() to be protected
  Fix CS
  [FrameworkBundle] Allow BrowserKit relative URL redirect assert
  [Messenger] RejectRedeliveredMessageException should not be retried
  [Serializer] Make `ProblemNormalizer` give details about Messenger’s `ValidationFailedException`
  [WebProfilerBundle] Support `!` negation operator in url filter
  ...
  • Loading branch information
fabpot committed Oct 2, 2023
2 parents c60db4c + 91dd39c commit f23f033
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 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
4 changes: 4 additions & 0 deletions SlackTransport.php
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

0 comments on commit f23f033

Please sign in to comment.