1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
LiveFeedCommentProcessor.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Space\List\RecentActivity\Event\Processor;
4
5use Bitrix\Socialnetwork\Internals\EventService\EventDictionary;
6use Bitrix\Socialnetwork\Space\List\RecentActivity\Dictionary;
7use Bitrix\Socialnetwork\Space\List\RecentActivity\Event\Data\LogRightProvider;
8use Bitrix\Socialnetwork\Space\List\RecentActivity\Event\Trait\AccessCodeTrait;
9
11{
12 use AccessCodeTrait;
13
14 public function isAvailable(): bool
15 {
16 return true;
17 }
18
19 protected function getTypeId(): string
20 {
21 return Dictionary::ENTITY_TYPE['livefeed_comment'];
22 }
23
24 private function doSkipEventProcessing(?string $eventId): bool
25 {
26 return in_array($eventId, ['tasks_comment', 'calendar_comment'], true);
27 }
28
29 public function process(): void
30 {
31 $sonetLogId = (int)($this->event->getData()['SONET_LOG_ID'] ?? null);
32 $eventId = $this->event->getData()['EVENT_ID'] ?? null;
33 $commentId = $this->event->getData()['SONET_LOG_COMMENT_ID'] ?? null;
34
35 if ($sonetLogId <= 0 || $commentId <= 0 ||$this->doSkipEventProcessing($eventId))
36 {
37 return;
38 }
39
40 switch ($this->event->getType())
41 {
42 case EventDictionary::EVENT_SPACE_LIVEFEED_COMMENT_ADD:
43 $this->onLiveFeedPostCommentAdd($sonetLogId, $commentId);
44 break;
45 case EventDictionary::EVENT_SPACE_LIVEFEED_COMMENT_DEL:
46 $this->onLiveFeedPostCommentDelete($commentId);
47 break;
48 default:
49 break;
50 }
51 }
52
53 private function onLiveFeedPostCommentAdd(int $sonetLogId, int $commentId): void
54 {
55 $spaceIds = $this->getSpaceIdsFromCodes((new LogRightProvider())->get($sonetLogId), $this->recipient);
56
57 $spaceIds = array_unique($spaceIds);
58 foreach ($spaceIds as $spaceId)
59 {
60 $this->saveRecentActivityData($spaceId, $commentId, $sonetLogId);
61 }
62 }
63
64 private function onLiveFeedPostCommentDelete(int $commentId): void
65 {
66 $this->deleteRecentActivityData($commentId);
67 }
68}
saveRecentActivityData(int $spaceId, int $entityId, ?int $secondaryEntityId=null)
Определения AbstractProcessor.php:31