Skip to content

Commit 838f36b

Browse files
committed
[Notifier] [Bridge] Store message id for slack transport's SendMessage
1 parent 2ad08d5 commit 838f36b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ protected function doSend(MessageInterface $message): SentMessage
9191
throw new TransportException(sprintf('Unable to post the Slack message: "%s".', $result['error']), $response);
9292
}
9393

94-
return new SentMessage($message, (string) $this);
94+
$sentMessage = new SentMessage($message, (string) $this);
95+
$sentMessage->setMessageId($result['ts']);
96+
97+
return $sentMessage;
9598
}
9699
}

src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function testSendWithOptions()
110110

111111
$response->expects($this->once())
112112
->method('getContent')
113-
->willReturn(json_encode(['ok' => true]));
113+
->willReturn(json_encode(['ok' => true, 'ts' => '1503435956.000247']));
114114

115115
$expectedBody = json_encode(['channel' => $channel, 'text' => $message]);
116116

@@ -122,7 +122,9 @@ public function testSendWithOptions()
122122

123123
$transport = $this->createTransport($client, $channel);
124124

125-
$transport->send(new ChatMessage('testMessage'));
125+
$sentMessage = $transport->send(new ChatMessage('testMessage'));
126+
127+
$this->assertSame('1503435956.000247', $sentMessage->getMessageId());
126128
}
127129

128130
public function testSendWithNotification()
@@ -138,7 +140,7 @@ public function testSendWithNotification()
138140

139141
$response->expects($this->once())
140142
->method('getContent')
141-
->willReturn(json_encode(['ok' => true]));
143+
->willReturn(json_encode(['ok' => true, 'ts' => '1503435956.000247']));
142144

143145
$notification = new Notification($message);
144146
$chatMessage = ChatMessage::fromNotification($notification);
@@ -158,7 +160,9 @@ public function testSendWithNotification()
158160

159161
$transport = $this->createTransport($client, $channel);
160162

161-
$transport->send($chatMessage);
163+
$sentMessage = $transport->send($chatMessage);
164+
165+
$this->assertSame('1503435956.000247', $sentMessage->getMessageId());
162166
}
163167

164168
public function testSendWithInvalidOptions()

0 commit comments

Comments
 (0)