1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
LiveFeedProcessor.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'];
22 }
23
24 private function doSkipEventProcessing(?string $eventId): bool
25 {
26 return in_array($eventId, ['calendar', 'tasks', '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 if ($sonetLogId <= 0 || $this->doSkipEventProcessing($eventId))
34 {
35 return;
36 }
37
38 switch ($this->event->getType())
39 {
40 case EventDictionary::EVENT_SPACE_LIVEFEED_POST_DEL:
41 $this->onLiveFeedPostDelete($sonetLogId);
42 break;
43 case EventDictionary::EVENT_SPACE_LIVEFEED_POST_REMOVE_USERS:
44 $this->onLiveFeedPostRemoveUsers($sonetLogId);
45 break;
46 default:
47 $this->onDefaultEvent($sonetLogId);
48 break;
49 }
50 }
51
52 private function onDefaultEvent(int $sonetLogId): void
53 {
54 $spaceIds = $this->getSpaceIdsFromCodes((new LogRightProvider())->get($sonetLogId), $this->recipient);
55
56 $spaceIds = array_unique($spaceIds);
57 foreach ($spaceIds as $spaceId)
58 {
59 $this->saveRecentActivityData($spaceId, $sonetLogId);
60 }
61 }
62
63 private function onLiveFeedPostDelete(int $sonetLogId): void
64 {
65 $this->deleteRecentActivityData($sonetLogId);
66 }
67
68 private function onLiveFeedPostRemoveUsers(int $sonetLogId): void
69 {
70 $this->deleteRecentActivityData($sonetLogId);
71 }
72}
saveRecentActivityData(int $spaceId, int $entityId, ?int $secondaryEntityId=null)
Определения AbstractProcessor.php:31