3declare(strict_types=1);
5namespace Bitrix\Im\V2\Anchor;
7use Bitrix\Im\Model\ChatTable;
8use Bitrix\Im\V2\Common\ContextCustomer;
9use Bitrix\Main\Application;
10use Bitrix\Main\Data\Cache;
16 private const CACHE_ID =
'user_anchors_';
17 private const CACHE_DIR =
'/bx/imc/anchors/';
18 private const CACHE_TTL = 60 * 60 * 24 * 30;
22 $userId ??= $this->getContext()->getUserId();
28 return $this->tryInitFromCache(
$userId);
45 $cacheId = self::CACHE_ID .
$userId;
46 $cacheDir = self::CACHE_DIR . $cacheId;
48 $cache->clean($cacheId, $cacheDir);
52 $cache->cleanDir(self::CACHE_DIR);
63 $map = array_fill_keys($chatIds, [
'PARENT_CHAT_ID' => 0,
'PARENT_MESSAGE_ID' => 0]);
65 $rows = ChatTable::query()
66 ->setSelect([
'ID',
'PARENT_ID',
'PARENT_MID'])
67 ->whereIn(
'ID', $chatIds)
71 foreach (
$rows as $row)
73 $chatId = (int)$row[
'ID'];
74 $chatParentId = (int)($row[
'PARENT_ID'] ?? 0);
75 $messageParentId = (int)($row[
'PARENT_MID'] ?? 0);
78 'PARENT_CHAT_ID' => $chatParentId,
79 'PARENT_MESSAGE_ID' => $messageParentId
90 $cacheId = self::CACHE_ID .
$userId;
91 $cacheDir = self::CACHE_DIR . $cacheId;
93 $cache->initCache(self::CACHE_TTL, $cacheId, $cacheDir);
101 $anchors = $cache->getVars();
102 if ($anchors ===
false)
107 $anchorCollection->fillParents($parents);
109 $anchors = $anchorCollection->toRestFormat();
111 $cache->startDataCache();
112 $cache->endDataCache($anchors);
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static find(array $filter, array $order=['MESSAGE_ID'=> 'desc'], ?int $limit=null, ?Context $context=null)
cleanUsersCache(array $userIds)
getUserAnchors(?int $userId=null)
getParentMap(array $chatIds)
cleanCache(int $userId=0)
getUserCache(int $userId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)