14 'onAfterCalendarEventDelete',
15 'onCalendarEventCommentAdd',
24 !class_exists(\
Bitrix\Socialnetwork\Space\Service::class)
25 || !Loader::includeModule(
'socialnetwork')
31 return \Bitrix\Socialnetwork\Space\Service::isAvailable();
34 public function addEvent(
string $type, array $data): void
36 if (!static::isAvailable())
41 if (!in_array($type, self::SUPPORTED_EVENTS,
true))
47 $data[
'RECEPIENTS'] = $this->getRecipientIds($data);
51 private function mapTaskToSpaceEvent(
string $type): string
55 'onAfterCalendarEventDelete' => EventDictionary::EVENT_SPACE_CALENDAR_EVENT_DEL,
56 'onCalendarEventCommentAdd' => EventDictionary::EVENT_SPACE_CALENDAR_EVENT_COMMENT_ADD,
62 private function getRecipientIds(array $data): array
64 if (isset($data[
'TO_USER_ID']))
66 return [$data[
'TO_USER_ID']];
69 if (is_array($data[
'ATTENDEE_LIST'] ??
null))
71 return $this->getRecipientFromAttendeeList($data[
'ATTENDEE_LIST']);
77 private function getRecipientFromAttendeeList(array $attendeeList): array
81 foreach ($attendeeList as $attendee)
83 if (!empty($attendee[
'id']))
85 $recipients[] = (int)$attendee[
'id'];