1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Mail.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2;
4
5use Bitrix\Im\Model\MessageUnreadTable;
6use Bitrix\Main\Config\Option;
7use Bitrix\Main\Type\DateTime;
8
9class Mail
10{
11 protected const LAST_SEND_MESSAGE = 'last_send_mail_message';
12 protected const LAST_SEND_NOTIFICATION = 'last_send_mail_notification';
13 protected const SEND_DELAY_OPTION_NAME = 'send_mail_delay_seconds';
14 protected const MODULE_ID = 'im';
15
16 protected const DEFAULT_SEND_DELAY = 600;
17
22 public function getMessageIdsToSend(): array
23 {
24 $lastSend = (int)Option::get(static::MODULE_ID, self::LAST_SEND_MESSAGE, 0);
25
26 return $this->getMessageIdsToSendByType(\IM_MESSAGE_PRIVATE, $lastSend);
27 }
28
33 public function getNotificationIdsToSend(?int $limit = null): array
34 {
35 $lastSend = (int)Option::get(static::MODULE_ID, self::LAST_SEND_NOTIFICATION, 0);
36
37 return $this->getMessageIdsToSendByType(\IM_MESSAGE_SYSTEM, $lastSend, $limit);
38 }
39
40 protected function getMessageIdsToSendByType(string $type, int $lastSend, ?int $limit = null): array
41 {
42 $sendDelayInSeconds = (int)Option::get(static::MODULE_ID, self::SEND_DELAY_OPTION_NAME, self::DEFAULT_SEND_DELAY);
43 $sendDelayInSeconds = abs($sendDelayInSeconds);
44 $readDeadline = (new DateTime())->add("-{$sendDelayInSeconds} seconds");
45 $query = MessageUnreadTable::query()
46 ->setSelect(['MESSAGE_ID'])
47 ->where('MESSAGE_ID', '>', $lastSend)
48 ->where('CHAT_TYPE', $type)
49 ->where('DATE_CREATE', '<', $readDeadline)
50 ;
51
52 if (isset($limit))
53 {
54 $query->setLimit($limit);
55 }
56
57 return $query
58 ->fetchCollection()
59 ->getMessageIdList()
60 ;
61 }
62}
$type
Определения options.php:106
const LAST_SEND_NOTIFICATION
Определения Mail.php:12
const DEFAULT_SEND_DELAY
Определения Mail.php:16
const MODULE_ID
Определения Mail.php:14
getNotificationIdsToSend(?int $limit=null)
Определения Mail.php:33
const SEND_DELAY_OPTION_NAME
Определения Mail.php:13
getMessageIdsToSend()
Определения Mail.php:22
const LAST_SEND_MESSAGE
Определения Mail.php:11
getMessageIdsToSendByType(string $type, int $lastSend, ?int $limit=null)
Определения Mail.php:40
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$query
Определения get_search.php:11
const IM_MESSAGE_SYSTEM
Определения include.php:21
const IM_MESSAGE_PRIVATE
Определения include.php:22
Определения address.php:8