Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Zoom.php
1<?php
2
4
10use CIMChat;
11
12class Zoom extends BaseController
13{
17 public function createAction(Chat $chat, CurrentUser $user): ?array
18 {
19 if (!\Bitrix\Im\Call\Integration\Zoom::isActive())
20 {
21 $this->addError(new CallError(CallError::ZOOM_ACTIVE_ERROR));
22
23 return null;
24 }
25
26 if (!\Bitrix\Im\Call\Integration\Zoom::isAvailable())
27 {
28 $this->addError(new CallError(CallError::ZOOM_AVAILABLE_ERROR));
29
30 return null;
31 }
32
33 if (!\Bitrix\Im\Call\Integration\Zoom::isConnected($user->getId()))
34 {
35 $this->addError(new CallError(CallError::ZOOM_CONNECTED_ERROR));
36
37 return null;
38 }
39
40 if (!$chat->canDo(Chat\Permission::ACTION_SEND))
41 {
43
44 return null;
45 }
46
47 $zoom = new \Bitrix\Im\Call\Integration\Zoom($user->getId(), $chat->getDialogId());
48 $link = $zoom->getImChatConferenceUrl();
49
50 if (empty($link))
51 {
52 $this->addError(new CallError(CallError::ZOOM_CREATE_ERROR));
53
54 return null;
55 }
56
57 $messageFields = $zoom->getRichMessageFields($chat->getDialogId(), $link, $user->getId());
58 $messageFields['PARAMS']['COMPONENT_ID'] = 'ZoomInviteMessage';
59 $messageFields['PARAMS']['COMPONENT_PARAMS'] = ['LINK' => $link];
60
61 $messageId = \CIMMessenger::Add($messageFields);
62
63 if (!$messageId)
64 {
65 $this->addError(new MessageError(MessageError::SENDING_FAILED));
66
67 return null;
68 }
69
70 return [
71 'link' => $link,
72 'messageId' => $messageId,
73 ];
74 }
75}
createAction(Chat $chat, CurrentUser $user)
Definition Zoom.php:17