Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
beta.php
1
<?php
2
3
4
namespace
Bitrix\Im\Controller\Call
;
5
6
7
use
Bitrix\Im\Alias
;
8
use
Bitrix\Im\Dialog
;
9
use
Bitrix\Im\Text
;
10
use
Bitrix\Im\User
;
11
use
Bitrix\Im\V2\Chat
;
12
use
Bitrix\Im\V2\Message
;
13
use
Bitrix\Im\V2\Message\Params
;
14
use
Bitrix\Main\Engine\Action
;
15
use
Bitrix\Main\Engine\Controller
;
16
use
Bitrix\Main\Engine\CurrentUser
;
17
use
Bitrix\Main\Error
;
18
use
Bitrix\Main\Loader
;
19
use
Bitrix\Main\Localization\Loc
;
20
21
class
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
}
Bitrix\Im\Alias
Definition
alias.php:8
Bitrix\Im\Alias\generateUnique
static generateUnique()
Definition
alias.php:226
Bitrix\Im\Controller\Call\Beta
Definition
beta.php:22
Bitrix\Im\Controller\Call\Beta\processBeforeAction
processBeforeAction(Action $action)
Definition
beta.php:23
Bitrix\Im\Controller\Call\Beta\createRoomAction
createRoomAction(CurrentUser $currentUser, string $dialogId="0", int $chatId=0)
Definition
beta.php:42
Bitrix\Im\Dialog
Definition
dialog.php:9
Bitrix\Im\Dialog\getChatId
static getChatId($dialogId, $userId=null)
Definition
dialog.php:91
Bitrix\Im\Text
Definition
text.php:9
Bitrix\Im\User
Definition
user.php:10
Bitrix\Im\User\getInstance
static getInstance($userId=null)
Definition
user.php:44
Bitrix\Im\V2\Chat\getInstance
static getInstance(?int $chatId)
Definition
Chat.php:282
Bitrix\Im\V2\Error
Definition
Error.php:8
Bitrix\Im\V2\Message\Params
Definition
Params.php:22
Bitrix\Im\V2\Message
Definition
Message.php:44
Bitrix\Main\Engine\Action
Definition
action.php:17
Bitrix\Main\Engine\Controller
Definition
controller.php:32
Bitrix\Main\Engine\Controller\addError
addError(Error $error)
Definition
controller.php:1051
Bitrix\Main\Engine\CurrentUser
Definition
currentuser.php:8
Bitrix\Main\Engine\CurrentUser\getId
getId()
Definition
currentuser.php:45
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Im\Controller\Call
Definition
beta.php:4
Bitrix\Im\V2\Chat
Definition
ChannelChat.php:3
Bitrix\Im\V2\Message
Definition
AdditionalMessagePopupItem.php:3
Bitrix\Sender\Internals\QueryController
Definition
action.php:8
modules
im
lib
controller
call
beta.php
Создано системой
1.10.0