1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ChatUserLeave.php
См. документацию.
1<?php
2
3declare(strict_types = 1);
4
5namespace Bitrix\Im\V2\Pull\Event;
6
7use Bitrix\Im\Text;
8use Bitrix\Im\V2\Chat\OpenLineChat;
9use Bitrix\Im\V2\Pull\EventType;
10use Bitrix\Im\V2\Chat;
11use Bitrix\Im\V2\Relation;
12use Bitrix\Im\V2\RelationCollection;
13
15{
16 protected int $deletedUserId;
18
20 {
21 $this->deletedUserId = $deletedUserId;
22 $this->relations = $relations;
23
24 parent::__construct($chat);
25 }
26
27 protected function getBasePullParamsInternal(): array
28 {
29 return [
30 'chatId' => $this->chat->getChatId(),
31 'dialogId' => $this->getBaseDialogId(),
32 'chatTitle' => Text::decodeEmoji($this->chat->getTitle() ?? ''),
33 'userId' => $this->deletedUserId,
34 'relations' => $this->chat->getRelationsByUserIds([$this->deletedUserId])->toRestFormat(),
35 'message' => $this->getLeaveMessageText(),
36 'userCount' => $this->chat->getUserCount(),
37 'chatExtranet' => $this->chat->getExtranet() ?? false,
38 'containsCollaber' => $this->chat->containsCollaber(),
39 ];
40 }
41
42 protected function getType(): EventType
43 {
45 }
46
47 protected function getSkippedUserIds(): array
48 {
49 if ($this->chat instanceof OpenLineChat)
50 {
51 $filteredRelations = $this->relations->filter(
52 fn (Relation $relation) => $relation->getUser()->getExternalAuthId() === 'imconnector',
53 );
54
55 return $filteredRelations->getUserIds();
56 }
57
58 return parent::getSkippedUserIds();
59 }
60
61 protected function getLeaveMessageText(): string
62 {
63 return
64 $this->deletedUserId !== $this->chat->getContext()->getUserId()
65 ? $this->chat->getUserDeleteMessageText($this->deletedUserId)
66 : ''
67 ;
68 }
69
70 protected function getRecipients(): array
71 {
72 return array_values($this->relations->getUserIds());
73 }
74}
static decodeEmoji($text)
Определения text.php:378
RelationCollection $relations
Определения ChatUserLeave.php:17
__construct(Chat $chat, int $deletedUserId, RelationCollection $relations)
Определения ChatUserLeave.php:19
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
EventType
Определения EventType.php:6
@ ChatUserLeave
Определения EventType.php:15