Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8b6a2d

Browse filesBrowse files
[Notifier] Fix thread key in GoogleChat bridge
Google Chat API has deprecated the use of `threadKey` query parameter in favor of `thread.threadKey` in request's body.
1 parent 916718c commit e8b6a2d
Copy full SHA for e8b6a2d

File tree

Expand file treeCollapse file tree

3 files changed

+16
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-4
lines changed

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoogleChat/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.2
5+
---
6+
7+
* Fix thread management with updated Google Chat API
8+
49
7.0
510
---
611

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,17 @@ protected function doSend(MessageInterface $message): SentMessage
9292
$this->space,
9393
urlencode($this->accessKey),
9494
urlencode($this->accessToken),
95-
$threadKey ? '&threadKey='.urlencode($threadKey) : ''
95+
$threadKey ? '&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD' : ''
9696
);
97+
98+
$body = array_filter($options->toArray());
99+
100+
if ($threadKey) {
101+
$body['thread']['threadKey'] = $threadKey;
102+
}
103+
97104
$response = $this->client->request('POST', $url, [
98-
'json' => array_filter($options->toArray()),
105+
'json' => $body,
99106
]);
100107

101108
try {

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public function testSendWithOptions()
108108
->method('getContent')
109109
->willReturn('{"name":"spaces/My-Space/messages/abcdefg.hijklmno"}');
110110

111-
$expectedBody = json_encode(['text' => $message]);
111+
$expectedBody = json_encode(['text' => $message, 'thread' => ['threadKey' => 'My-Thread']]);
112112

113113
$client = new MockHttpClient(function (string $method, string $url, array $options = []) use ($response, $expectedBody): ResponseInterface {
114114
$this->assertSame('POST', $method);
115-
$this->assertSame('https://chat.googleapis.com/v1/spaces/My-Space/messages?key=theAccessKey&token=theAccessToken%3D&threadKey=My-Thread', $url);
115+
$this->assertSame('https://chat.googleapis.com/v1/spaces/My-Space/messages?key=theAccessKey&token=theAccessToken%3D&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD', $url);
116116
$this->assertSame($expectedBody, $options['body']);
117117

118118
return $response;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.