Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Chats.php
1<?php
2
4
9
10class Chats implements Entity
11{
12 private array $chatIds = [];
13 private array $shortInfoChatIds = [];
14 private bool $readAll = false;
15
16 public function add(Event $event): void
17 {
18 $entityId = $event->entityId;
19 switch ($event->eventName)
20 {
22 $this->shortInfoChatIds[$entityId] = $entityId;
23 break;
25 $this->chatIds[$entityId] = $entityId;
26 break;
28 $this->readAll = true;
29 break;
30 }
31 }
32
33 public function getData(): array
34 {
35 $addedRecent = [];
36 $addedChats = [];
37
38 if (!empty($this->chatIds))
39 {
40 $addedRecent = Recent::get(null, ['JSON' => 'Y', 'CHAT_IDS' => $this->chatIds, 'SKIP_OPENLINES' => 'Y']);
41 $addedChats = Chat::getList(['FILTER' => ['ID' => $this->chatIds], 'JSON' => true, 'SKIP_ACCESS_CHECK' => 'Y']);
42 }
43
44 $result = [
45 'addedRecent' => $addedRecent,
46 'addedChats' => $addedChats,
47 'deletedChats' => $this->shortInfoChatIds,
48 ];
49
50 if ($this->readAll)
51 {
52 $result['readAllChats'] = true;
53 }
54
55 return $result;
56 }
57}
static getList($params=array())
Definition chat.php:926
static get($userId=null, $options=[])
Definition recent.php:31