Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
Chats.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Sync\Entity
;
4
5
use
Bitrix\Im\Chat
;
6
use
Bitrix\Im\Recent
;
7
use
Bitrix\Im\V2\Sync\Entity
;
8
use
Bitrix\Im\V2\Sync\Event
;
9
10
class
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
{
21
case
Event::DELETE_EVENT
:
22
$this->shortInfoChatIds[$entityId] = $entityId;
23
break
;
24
case
Event::ADD_EVENT
:
25
$this->chatIds[$entityId] = $entityId;
26
break
;
27
case
Event::READ_ALL_EVENT
:
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
}
Bitrix\Im\Chat
Definition
chat.php:19
Bitrix\Im\Chat\getList
static getList($params=array())
Definition
chat.php:926
Bitrix\Im\Recent
Definition
recent.php:26
Bitrix\Im\Recent\get
static get($userId=null, $options=[])
Definition
recent.php:31
Bitrix\Im\V2\Sync\Entity\Chats
Definition
Chats.php:11
Bitrix\Im\V2\Sync\Entity\Chats\add
add(Event $event)
Definition
Chats.php:16
Bitrix\Im\V2\Sync\Entity\Chats\getData
getData()
Definition
Chats.php:33
Bitrix\Im\V2\Sync\Event
Definition
Event.php:9
Bitrix\Im\V2\Sync\Event\DELETE_EVENT
const DELETE_EVENT
Definition
Event.php:10
Bitrix\Im\V2\Sync\Event\READ_ALL_EVENT
const READ_ALL_EVENT
Definition
Event.php:13
Bitrix\Im\V2\Sync\Event\ADD_EVENT
const ADD_EVENT
Definition
Event.php:12
Bitrix\Im\V2\Sync\Entity
Definition
Entity.php:6
Bitrix\Im\V2\Sync\Entity
Definition
Chats.php:3
modules
im
lib
V2
Sync
Entity
Chats.php
Создано системой
1.10.0