1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ChannelChat.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Chat;
4
5use Bitrix\Im\Recent;
6use Bitrix\Im\V2\Chat;
7use Bitrix\Im\V2\Message\ReadService;
8use Bitrix\Main\Config\Option;
9use Bitrix\Main\Loader;
10use Bitrix\Main\Localization\Loc;
11use Bitrix\Main\Type\DateTime;
12
14{
15 private const MESSAGE_COMPONENT_START_CHANNEL = 'ChannelCreationMessage';
16
17 public function extendPullWatch(): void
18 {
19 if (!Loader::includeModule('pull'))
20 {
21 return;
22 }
23
24 \CPullWatch::Add($this->getContext()->getUserId(), "IM_PUBLIC_COMMENT_{$this->getId()}", true);
25 }
26
27 protected function updateStateAfterRelationsAdd(array $usersToAdd): Chat
28 {
29 $result = parent::updateStateAfterRelationsAdd($usersToAdd);
30 Recent::raiseChat($this, $this->getRelationsByUserIds($usersToAdd), new DateTime());
31
32 return $result;
33 }
34
35 protected function sendGreetingMessage(?int $authorId = null)
36 {
37 $messageText = Loc::getMessage('IM_CHANNEL_CREATE');
38
40 'MESSAGE_TYPE' => $this->getType(),
41 'TO_CHAT_ID' => $this->getChatId(),
42 'FROM_USER_ID' => 0,
43 'MESSAGE' => $messageText,
44 'SYSTEM' => 'Y',
45 'PUSH' => 'N',
46 'SKIP_COUNTER_INCREMENTS' => 'Y',
47 'PARAMS' => [
48 'NOTIFY' => 'N',
49 ],
50 ]);
51 }
52
53 protected function getDefaultType(): string
54 {
55 return self::IM_TYPE_CHANNEL;
56 }
57
58 public function getDefaultManageMessages(): string
59 {
60 return self::MANAGE_RIGHTS_MANAGERS;
61 }
62
63 public function getDefaultManageUI(): string
64 {
65 return self::MANAGE_RIGHTS_MANAGERS;
66 }
67
68 public function realAllComments(): void
69 {
70 $readComments = (new ReadService())->readChildren($this);
71
72 if (empty($readComments) || !Loader::includeModule('pull'))
73 {
74 return;
75 }
76
77 $pushMessage = [
78 'module_id' => 'im',
79 'command' => 'readAllChannelComments',
80 'params' => [
81 'chatId' => $this->getChatId(),
82 ],
84 ];
85
86 \Bitrix\Pull\Event::add($this->getContext()->getUserId(), $pushMessage);
87 }
88
89 protected function sendBanner(?int $authorId = null): void
90 {
92 'MESSAGE_TYPE' => $this->getType(),
93 'TO_CHAT_ID' => $this->getChatId(),
94 'FROM_USER_ID' => 0,
95 'MESSAGE' => Loc::getMessage('IM_CHAT_CHANNEL_CREATE_WELCOME'),
96 'SYSTEM' => 'Y',
97 'PUSH' => 'N',
98 'PARAMS' => [
99 'COMPONENT_ID' => self::MESSAGE_COMPONENT_START_CHANNEL,
100 ],
101 'SKIP_COUNTER_INCREMENTS' => 'Y',
102 ]);
103 }
104
105 protected function needToSendMessageUserDelete(): bool
106 {
107 return false;
108 }
109}
static getType($chatData, bool $camelCase=true)
Определения chat.php:45
static getPullExtra()
Определения common.php:127
static raiseChat(\Bitrix\Im\V2\Chat $chat, RelationCollection $relations, ?DateTime $lastActivity=null)
Определения recent.php:1582
updateStateAfterRelationsAdd(array $usersToAdd)
Определения ChannelChat.php:27
needToSendMessageUserDelete()
Определения ChannelChat.php:105
sendBanner(?int $authorId=null)
Определения ChannelChat.php:89
sendGreetingMessage(?int $authorId=null)
Определения ChannelChat.php:35
getDefaultManageMessages()
Определения ChannelChat.php:58
static add($recipient, array $parameters, $channelType=\CPullChannel::TYPE_PRIVATE)
Определения event.php:22
static Add($arFields)
Определения im_message.php:28
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14