Skip to content

Commit bc54ad8

Browse files
authored
Merge pull request #175 from ricardoapaes/add_support_thread_messages_zoho_cliq
feat(zohocliq): Full Thread support with Title and Posting Options
2 parents ef88fb9 + 2d39706 commit bc54ad8

File tree

6 files changed

+68
-3
lines changed

6 files changed

+68
-3
lines changed

src/ZohoCliq/Messages/ChannelMessage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class ChannelMessage extends Message
3333
'styles',
3434
'slides',
3535
'buttons',
36+
37+
// To send message in thread
38+
'thread_message_id',
39+
'thread_title',
40+
'post_in_parent',
3641
];
3742

3843
public function toHttpUri(): string

src/ZohoCliq/Messages/ChatMessage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class ChatMessage extends Message
3333
'styles',
3434
'slides',
3535
'buttons',
36+
37+
// To send message in thread
38+
'thread_message_id',
39+
'thread_title',
40+
'post_in_parent',
3641
];
3742

3843
public function toHttpUri(): string

src/ZohoCliq/Messages/Message.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727
abstract class Message extends \Guanguans\Notify\Foundation\Message
2828
{
29+
use ThreadConfig;
2930
protected array $required = [
3031
// 'channel_unique_name',
3132
// 'bot_unique_name',
@@ -40,6 +41,11 @@ abstract class Message extends \Guanguans\Notify\Foundation\Message
4041
'styles',
4142
'slides',
4243
'buttons',
44+
45+
// To send message in thread
46+
'thread_message_id',
47+
'thread_title',
48+
'post_in_parent',
4349
];
4450
protected array $allowedTypes = [
4551
'bot' => 'array',
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) 2021-2025 guanguans<[email protected]>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*
11+
* @see https://github.com/guanguans/notify
12+
*/
13+
14+
namespace Guanguans\Notify\ZohoCliq\Messages;
15+
16+
trait ThreadConfig
17+
{
18+
final public function setThreadId(int $slice01, int $slice02): self
19+
{
20+
$this->options['thread_message_id'] = \sprintf('%s_%s', $slice01, $slice02);
21+
22+
return $this;
23+
}
24+
25+
final public function setThreadTitle(string $title): self
26+
{
27+
$this->options['thread_title'] = $title;
28+
29+
return $this;
30+
}
31+
32+
final public function setThreadPostInParent(): self
33+
{
34+
$this->options['post_in_parent'] = true;
35+
36+
return $this;
37+
}
38+
}

tests/ZohoCliq/ClientTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,21 @@
147147
})->group(__DIR__, __FILE__);
148148

149149
it('can send channel message', function (): void {
150-
$channelMessage = ChannelMessage::make($this->message)->channelUniqueName('announcements');
150+
$channelMessage = ChannelMessage::make($this->message)
151+
->channelUniqueName('announcements')
152+
->setThreadId(123, 123)
153+
->setThreadTitle('Thread Title')
154+
->setThreadPostInParent();
151155

152156
expect($this->client)->assertCanSendMessage($channelMessage);
153157
})->group(__DIR__, __FILE__);
154158

155159
it('can send chat message', function (): void {
156-
$chatMessage = ChatMessage::make($this->message)->chatId('CT_2242272070192345152_905914233-B1');
160+
$chatMessage = ChatMessage::make($this->message)
161+
->chatId('CT_2242272070192345152_905914233-B1')
162+
->setThreadId(123, 123)
163+
->setThreadTitle('Thread Title')
164+
->setThreadPostInParent();
157165

158166
expect($this->client)->assertCanSendMessage($chatMessage);
159167
})->group(__DIR__, __FILE__);

tests/ZohoCliqWebHook/ClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@
9595
'name' => 'internlist',
9696
],
9797
],
98-
]);
98+
])
99+
->setThreadId(123, 123)
100+
->setThreadTitle('Thread Title')
101+
->setThreadPostInParent();
99102

100103
expect($client)
101104
->mock([

0 commit comments

Comments
 (0)