3namespace Bitrix\Socialnetwork\Internals\LiveFeed\Counter;
5use Bitrix\Socialnetwork\Internals\EventService\Event;
6use Bitrix\Socialnetwork\Internals\EventService\EventDictionary;
7use Bitrix\Socialnetwork\Internals\LiveFeed\Counter;
8use Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Processor\CommandTrait;
9use Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Processor\UserProcessor;
10use Bitrix\Socialnetwork\Livefeed\Provider;
11use Bitrix\Socialnetwork\Space\Service;
12use Bitrix\Socialnetwork\UserContentViewTable;
27 $this->userId = $userId;
34 public static function isEnabled(
int $userId = 0): bool
36 return Service::isAvailable(
true);
46 if (
$event->getType() === EventDictionary::EVENT_SPACE_LIVEFEED_COUNTER_UPD)
58 case EventDictionary::EVENT_SPACE_LIVEFEED_READ_ALL:
61 case EventDictionary::EVENT_SPACE_LIVEFEED_POST_VIEW:
64 case EventDictionary::EVENT_SPACE_LIVEFEED_POST_ADD:
67 case EventDictionary::EVENT_SPACE_LIVEFEED_COMMENT_ADD:
70 case EventDictionary::EVENT_SPACE_LIVEFEED_POST_DEL:
73 case EventDictionary::EVENT_SPACE_LIVEFEED_COMMENT_DEL:
91 $type = $queueItem[
'TYPE'] ??
null;
92 $items = $queueItem[
'SONET_LOGS'] ??
null;
115 if (!$this->isSameValueCached($value))
130 $sonetLogId =
$event->getData()[
'SONET_LOG_ID'] ??
null;
139 $userProcessor->recount(
$counter, [$sonetLogId]);
145 $sonetLogId =
$event->getData()[
'SONET_LOG_ID'] ??
null;
154 $userProcessor->add(
$counter, [$sonetLogId]);
160 $sonetLogId =
$event->getData()[
'SONET_LOG_ID'] ??
null;
169 $userProcessor->seen(
$counter, [$sonetLogId]);
173 private function seen(Event
$event): void
176 if (!isset(
$data[
'ENTITY_ID'],
$data[
'ENTITY_TYPE_ID'],
$data[
'USER_ID'],
$data[
'SONET_LOG_ID']))
193 self::reset($this->userId);
198 $this->saveFlag($this->userId);
208 $groupId = (int)(
$event->getData()[
'GROUP_ID'] ?? 0);
213 'typeId' => Provider::DATA_ENTITY_TYPE_LIVE_FEED_VIEW,
214 'entityId' => $groupId,
222 private function isSameValueCached(
int $value): bool
232 foreach ($cache as $item)
236 && $item[
'SITE_ID'] ===
'**'
237 && (
int)$item[
'CNT'] === $value
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
__construct(int $userId=0)
static isEnabled(int $userId=0)
processQueueItem(array $queueItem)
const COUNTER_NEW_COMMENTS
static getInstance(int $userId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)