1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
notify.php
См. документацию.
1
<?php
2
namespace
Bitrix\Im\Update;
3
4
class
Notify
5
{
6
public
static
function
removeDuplicateChatAgent
()
7
{
8
$hasDuplicate =
false
;
9
$connection
=
\Bitrix\Main\Application::getInstance
()->getConnection();
10
$users =
$connection
->query(
"
11
SELECT AUTHOR_ID, COUNT(1) CNT
12
FROM b_im_chat
13
WHERE TYPE = '"
.
IM_MESSAGE_SYSTEM
.
"'
14
GROUP BY AUTHOR_ID
15
HAVING CNT > 1
16
LIMIT 100
17
"
);
18
while
($userData = $users->fetch())
19
{
20
$hasDuplicate =
true
;
21
22
$result
= Array();
23
$chats =
$connection
->query(
"
24
SELECT ID, LAST_MESSAGE_ID
25
FROM b_im_chat
26
WHERE TYPE = '"
.
IM_MESSAGE_SYSTEM
.
"' AND AUTHOR_ID = "
.intval($userData[
'AUTHOR_ID'
]).
"
27
"
);
28
while
($chatData = $chats->fetch())
29
{
30
$result
[intval($chatData[
'ID'
])] = intval($chatData[
'LAST_MESSAGE_ID'
]);
31
}
32
arsort(
$result
);
33
$result
= array_slice(
$result
, 1,
null
,
true
);
34
$chatId = array_keys(
$result
);
35
if
(!empty($chatId))
36
{
37
$connection
->query(
"DELETE FROM b_im_relation WHERE CHAT_ID IN ("
.implode(
", "
, $chatId).
")"
);
38
$connection
->query(
"DELETE FROM b_im_chat WHERE ID IN ("
.implode(
", "
, $chatId).
")"
);
39
}
40
}
41
42
return
$hasDuplicate?
"\Bitrix\Im\Update\Notify::removeDuplicateChatAgent();"
:
""
;
43
}
44
}
$connection
$connection
Определения
actionsdefinitions.php:38
Bitrix\Im\Notify
Определения
notify.php:18
Bitrix\Im\Update\Notify\removeDuplicateChatAgent
static removeDuplicateChatAgent()
Определения
notify.php:6
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
$result
$result
Определения
get_property_values.php:14
IM_MESSAGE_SYSTEM
const IM_MESSAGE_SYSTEM
Определения
include.php:21
bitrix
modules
im
lib
update
notify.php
Создано системой
1.14.0