1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
dummy.php
См. документацию.
1<?php
3
10{
11 public const ID = 'dummy';
12
13 public function getId()
14 {
15 return static::ID;
16 }
17
18 public function getName()
19 {
20 return 'Dummy SMS';
21 }
22
23 public function getShortName()
24 {
25 return $this->getName();
26 }
27
28 public function getFromList()
29 {
30 return [
31 [
32 'id' => 'test',
33 'name' => 'test',
34 ]
35 ];
36 }
37
38 public function sendMessage(array $messageFieldsFields)
39 {
40 $messageFieldsFields['MESSAGE_BODY'] = $this->prepareMessageBodyForSend($messageFieldsFields['MESSAGE_BODY']);
41 AddMessage2Log($messageFieldsFields);
42
43 $result = new \Bitrix\MessageService\Sender\Result\SendMessage();
45 $result->setExternalId(uniqid());
46
47 $dialogId = \Bitrix\Main\Config\Option::get('messageservice', 'dummy_dialog_id', '');
48 if (
49 !empty($dialogId)
50 && \Bitrix\Main\Loader::includeModule('im')
51 && \Bitrix\Im\Common::isChatId($dialogId)
52 )
53 {
54 $messageFieldsFields['provider_settings'] = [
55 "socketTimeout" => $this->socketTimeout,
56 "streamTimeout" => $this->streamTimeout,
57 ];
58
59 \CIMChat::AddMessage([
60 'DIALOG_ID' => $dialogId,
61 'USER_ID' => 0,
62 'SYSTEM' => 'Y',
63 'MESSAGE' => '[b]MessageService test message[/b] :idea: [br][br]' . print_r($messageFieldsFields, 1),
64 ]);
65 }
66
67 // emulation of the delay in sending a request to the provider
68 $timeout = (int)\Bitrix\Main\Config\Option::get('messageservice', 'dummy_timeout_ms');
69 if ($timeout > 0)
70 {
71 usleep($timeout * 1000);
72 }
73
74 return $result;
75 }
76
77 public function canUse()
78 {
79 return true;
80 }
81
82 public static function onGetSmsSenders()
83 {
84 return [new self()];
85 }
86}
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
int $socketTimeout
Определения base.php:16
int $streamTimeout
Определения base.php:17
prepareMessageBodyForSend(string $text)
Определения base.php:177
sendMessage(array $messageFieldsFields)
Определения dummy.php:38
static onGetSmsSenders()
Определения dummy.php:82
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
AddMessage2Log($text, $module='', $traceDepth=6, $showArgs=false)
Определения tools.php:3941