• Модуль: imconnector
  • Путь к файлу: ~/bitrix/modules/imconnector/lib/connector.php
  • Класс: BitrixImConnectorConnector
  • Вызов: Connector::sendMessageProcessing
static function sendMessageProcessing(array $message): array
{
	$richData = [];
	if (!empty($message['message']['attachments']) && is_array($message['message']['attachments']))
	{
		foreach ($message['message']['attachments'] as $attachment)
		{
			$attachment = BitrixMainWebJson::decode($attachment);
			if (isset($attachment['BLOCKS']) && is_array($attachment['BLOCKS']))
			{
				foreach ($attachment['BLOCKS'] as $block)
				{
					if (isset($block['RICH_LINK']) && is_array($block['RICH_LINK']))
					{
						foreach ($block['RICH_LINK'] as $richData)
						{
							if (!empty($richData))
							{
								if ($richData['LINK'])
								{
									$richData['richData']['url'] = $richData['LINK'];
								}

								if ($richData['NAME'])
								{
									$richData['richData']['title'] = $richData['NAME'];
								}

								if ($richData['DESC'])
								{
									$richData['richData']['description'] = $richData['DESC'];
								}

								if ($richData['PREVIEW'])
								{
									$uri = new Uri($richData['PREVIEW']);
									if ($uri->getHost())
									{
										$richData['richData']['image'] = $richData['PREVIEW'];
									}
									else
									{
										$richData['richData']['image'] = self::getDomainDefault() .'/'. $richData['PREVIEW'];
									}
								}
								elseif($richData['EXTRA_IMAGE'])
								{
									$richData['richData']['image'] = $richData['EXTRA_IMAGE'];
								}
							}
						}
					}
				}
			}
		}
	}

	$message['message']['attachments'] = $richData;

	return $message;
}