1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
beta.php
См. документацию.
1<?php
2
3
5
6
20
21class Beta extends Controller
22{
23 protected function processBeforeAction(Action $action): bool
24 {
25 if (!Loader::includeModule('im'))
26 {
27 $this->addError(new Error("Module IM is not installed"));
28
29 return false;
30 }
31
32 if (User::getInstance()->isExtranet())
33 {
34 $this->addError(new Error("You dont have access to this action"));
35
36 return false;
37 }
38
39 return true;
40 }
41
42 public function createRoomAction(CurrentUser $currentUser, string $dialogId = "0", int $chatId = 0)
43 {
44 if ($dialogId > 0)
45 {
46 $chatId = Dialog::getChatId($dialogId, $currentUser->getId());
47 }
48 if ($chatId <= 0)
49 {
50 $this->addError(new Error("You must be specified chatId or dialogId"));
51 return null;
52 }
53
54 $chat = Chat::getInstance($chatId);
55
56 if (!$chat->hasAccess())
57 {
58 $this->addError(new Error("You must be a member of the chat to call it"));
59
60 return null;
61 }
62
63 $roomId = $chatId.'_'. Alias::generateUnique();
64 $link = 'https://demo-stage.webrtc-test.bitrix.info/?roomId='.$roomId;
65
66 $text = Loc::getMessage("IM_CALL_BETA_INVITE", [
67 '#LINK#' => '[URL='.$link.']'.Loc::getMessage('IM_CALL_BETA_INVITE_BUTTON').'[/URL]',
68 ]);
69
70 $message = new Message();
71 $message->setMessage($text)->markAsImportant(true);
72 $message->getParams()
73 ->fill([
74 Params::COMPONENT_ID => 'CallInviteMessage',
75 Params::COMPONENT_PARAMS => [
76 'LINK' => $link
77 ]
78 ])
79 ->save()
80 ;
81 $chat->sendMessage($message);
82
83 return true;
84 }
85}
Определения alias.php:9
static generateUnique()
Определения alias.php:242
processBeforeAction(Action $action)
Определения beta.php:23
createRoomAction(CurrentUser $currentUser, string $dialogId="0", int $chatId=0)
Определения beta.php:42
Определения dialog.php:11
static getChatId($dialogId, $userId=null)
Определения dialog.php:93
static getInstance($userId=null)
Определения user.php:45
static getInstance()
Определения application.php:98
addError(Error $error)
Определения controller.php:1070
Определения error.php:15
Определения loader.php:13
Определения Uuid.php:3
Определения base32.php:2
$message
Определения payment.php:8
$text
Определения template_pdf.php:79
$action
Определения file_dialog.php:21