Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
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();
44 $result->setStatus(\Bitrix\MessageService\MessageStatus::DELIVERED);
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 return $result;
68 }
69
70 public function canUse()
71 {
72 return true;
73 }
74
75 public static function onGetSmsSenders()
76 {
77 return [new self()];
78 }
79}
prepareMessageBodyForSend(string $text)
Definition base.php:176
sendMessage(array $messageFieldsFields)
Definition dummy.php:38