AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 18.119.29.70
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/integration/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/messageservice/lib/integration/pull.php
<?php

namespace Bitrix\MessageService\Integration;

use Bitrix\Main\Loader;
use Bitrix\Main\Type\DateTime;

class Pull
{
	public const TAG = 'MESSAGESERVICE';
	public const COMMAND = 'message_update';

	private static $canUse;

	public static function canUse()
	{
		if (static::$canUse === null)
		{
			static::$canUse = Loader::includeModule('pull');
		}
		return static::$canUse;
	}

	public static function onMessagesUpdate(array $messages)
	{
		if (!static::canUse())
		{
			return false;
		}

		return static::addToStack(
			self::COMMAND,
			[
				'messages' => static::convertData($messages)
			]
		);
	}

	/**
	 * @param string $command Pull command name.
	 * @param array $params Command parameters.
	 * @return bool
	 */
	private static function addToStack($command, array $params)
	{
		if (!static::canUse())
		{
			return false;
		}

		return \CPullWatch::addToStack(
			self::TAG,
			array(
				'module_id' => 'messageservice',
				'command' => $command,
				'params' => $params,
			)
		);
	}

	/**
	 * Converts message fields to the suitable for sending via p&p format.
	 *
	 * @param array $messages
	 * @return array
	 */
	private static function convertData(array $messages): array
	{
		foreach($messages as $k => $message)
		{
			foreach ($message as $field => $value)
			{
				if ($value instanceof DateTime)
				{
					$messages[$k][$field] = (string)$value;
				}
			}
		}

		return $messages;
	}
}

Anon7 - 2022
AnonSec Team