diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php b/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php index 5a98638ab30d5..740a4937ebd6b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php @@ -91,6 +91,9 @@ protected function doSend(MessageInterface $message): SentMessage throw new TransportException(sprintf('Unable to post the Slack message: "%s".', $result['error']), $response); } - return new SentMessage($message, (string) $this); + $sentMessage = new SentMessage($message, (string) $this); + $sentMessage->setMessageId($result['ts']); + + return $sentMessage; } } diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php index 3b7a3c6f8ff64..12e00e3f4a951 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php @@ -110,7 +110,7 @@ public function testSendWithOptions() $response->expects($this->once()) ->method('getContent') - ->willReturn(json_encode(['ok' => true])); + ->willReturn(json_encode(['ok' => true, 'ts' => '1503435956.000247'])); $expectedBody = json_encode(['channel' => $channel, 'text' => $message]); @@ -122,7 +122,9 @@ public function testSendWithOptions() $transport = $this->createTransport($client, $channel); - $transport->send(new ChatMessage('testMessage')); + $sentMessage = $transport->send(new ChatMessage('testMessage')); + + $this->assertSame('1503435956.000247', $sentMessage->getMessageId()); } public function testSendWithNotification() @@ -138,7 +140,7 @@ public function testSendWithNotification() $response->expects($this->once()) ->method('getContent') - ->willReturn(json_encode(['ok' => true])); + ->willReturn(json_encode(['ok' => true, 'ts' => '1503435956.000247'])); $notification = new Notification($message); $chatMessage = ChatMessage::fromNotification($notification); @@ -158,7 +160,9 @@ public function testSendWithNotification() $transport = $this->createTransport($client, $channel); - $transport->send($chatMessage); + $sentMessage = $transport->send($chatMessage); + + $this->assertSame('1503435956.000247', $sentMessage->getMessageId()); } public function testSendWithInvalidOptions()