3namespace Bitrix\Im\V2\TariffLimit;
5use Bitrix\Bitrix24\Feature;
7use Bitrix\Im\V2\Integration\AiAssistant\AiAssistantService;
8use Bitrix\Main\DI\ServiceLocator;
10use Bitrix\Main\Type\DateTime;
14 private const DAYS_LIMIT_HISTORY_VARIABLE =
'im_history_days_limit';
15 private const HISTORY_LIMIT_ID =
'im_history_limit';
16 private const CHAT_TYPE_BLACKLIST = [
17 Chat\ChannelChat::class,
18 Chat\CommentChat::class,
19 Chat\CollabChat::class,
20 Chat\ExternalChat::class
23 private static ?
self $instance;
27 private function __construct()
29 $this->aiAssistantService = ServiceLocator::getInstance()->get(AiAssistantService::class);
34 if (!isset(static::$instance))
36 static::$instance =
new static();
39 return static::$instance;
44 if (Loader::includeModule(
'pull'))
46 \CPullStack::AddShared([
48 'command' =>
'changeTariff',
60 'fullChatHistory' => [
69 if (!Loader::includeModule(
'bitrix24'))
74 if (Feature::isFeatureEnabled(self::HISTORY_LIMIT_ID))
79 $limitDays = Feature::getVariable(self::DAYS_LIMIT_HISTORY_VARIABLE);
81 return $limitDays ===
null ? null : (int)$limitDays;
113 return $this->isChatTypeAllowed($chatId);
118 Loader::requireModule(
'bitrix24');
121 return (
new DateTime())->add(
"-{$days} days");
124 private function isChatTypeAllowed(
int $chatId): bool
127 foreach (self::CHAT_TYPE_BLACKLIST as
$type)
129 if ($chat instanceof
$type)
135 if ($this->aiAssistantService->isAiAssistantChat($chat))
static onLicenseHasChanged()
shouldFilterByDate(DateFilterable $item)
hasAccessByDate(DateFilterable $item, DateTime $date)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)