27 'DIALOG_UNREAD' => [],
37 if ($counter[
'CHAT_TYPE'] === \IM_MESSAGE_PRIVATE)
39 $privateChatIds[] = $counter[
'CHAT_ID'];
47 $chatId = (int)$counter[
'CHAT_ID'];
48 $count = (int)$counter[
'COUNT'];
49 if ($counter[
'IS_MUTED'] ===
'Y')
53 else if ($counter[
'CHAT_TYPE'] === \IM_MESSAGE_SYSTEM)
57 else if ($counter[
'CHAT_TYPE'] === \IM_MESSAGE_OPEN_LINE)
61 else if ($counter[
'CHAT_TYPE'] === \IM_MESSAGE_PRIVATE && isset($chatIdToDialogId[$chatId]))
73 $this->countersByChatIds[$chatId] = $count;
78 $query = RecentTable::query()
79 ->setSelect([
'CHAT_ID' =>
'ITEM_CID',
'IS_MUTED' =>
'RELATION.NOTIFY_BLOCK',
'DIALOG_ID' =>
'ITEM_ID',
'ITEM_TYPE'])
80 ->where(
'USER_ID', $this->getContext()->getUserId())
81 ->where(
'UNREAD',
true)
85 $query->where(
'IS_MUTED', $isMuted);
88 return $query->fetchAll();
95 foreach ($unreadChats as $unreadChat)
97 if ($unreadChat[
'ITEM_TYPE'] === \IM_MESSAGE_PRIVATE)
103 $this->
setUnreadChat((
int)$unreadChat[
'CHAT_ID'], $unreadChat[
'IS_MUTED'] ===
'Y');
110 $this->counters[
'TYPE'][
'ALL']++;
111 $this->counters[
'TYPE'][
'DIALOG']++;
112 $this->counters[
'DIALOG_UNREAD'][] = $id;
117 $this->counters[
'TYPE'][
'ALL'] += $count;
118 $this->counters[
'TYPE'][
'DIALOG'] += $count;
119 $this->counters[
'DIALOG'][$id] = $count;
124 if (empty($privateChatIds))
129 $result = RelationTable::query()
130 ->setSelect([
'USER_ID',
'CHAT_ID'])
131 ->whereNot(
'USER_ID', $this->getContext()->getUserId())
132 ->whereIn(
'CHAT_ID', $privateChatIds)
138 foreach ($result as $row)
140 $map[$row[
'CHAT_ID']] = $row[
'USER_ID'];
setUnreadChat(int $id, bool $isMuted)
setFromNotify(int $count)
setFromLine(int $id, int $count)
setFromMutedChat(int $id, int $count)
getCountersForEachChat(?array $chatIds=null, bool $forCurrentUser=true)
setFromChat(int $id, int $count)
getUnreadChats(?bool $isMuted=null)
setFromDialog(int $id, int $count)
countUnreadMessages(?array $chatIds=null)
getMapChatToDialog(array $privateChatIds)