1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
MessagesAutoDeleteDelay.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Collab\Control\Option\Type;
4
5use Bitrix\Im\V2\Chat;
6use Bitrix\Im\V2\Message\Delete\DisappearService;
7use Bitrix\Main\Result;
8use Bitrix\Main\Validation\Rule\InArray;
9use Bitrix\Socialnetwork\Collab\Collab;
10use Bitrix\Socialnetwork\Collab\Control\Option\AbstractOption;
11
13{
14 public const NAME = 'messagesAutoDeleteDelay';
15 public const DB_NAME = 'MESSAGES_AUTO_DELETE_DELAY';
16
20 public const DEFAULT_VALUE = '';
21
25 public const ALLOWED_VALUES = [
26 self::DEFAULT_VALUE,
27 '0',
28 '1',
29 '24',
30 '168',
31 '720',
32 ];
33
34 #[InArray(self::ALLOWED_VALUES)]
35 protected string $value;
36
37 protected bool $needUpdate = false;
38
39 public function __construct(string $value)
40 {
41 $this->checkNeedUpdate($value);
42 parent::__construct(static::DB_NAME, $value);
43 }
44
45 protected function applyImplementation(Collab $collab): Result
46 {
47 if (!$this->needUpdate)
48 {
49 return new Result();
50 }
51
52 return \Bitrix\Socialnetwork\Collab\Integration\IM\Chat::updateMessagesAutoDelete(
53 $collab->getChatId(),
54 (int)$this->getValue()
55 );
56 }
57
58 protected function checkNeedUpdate(string $value): void
59 {
60 if ($value !== self::DEFAULT_VALUE)
61 {
62 $this->needUpdate = true;
63 }
64 }
65}
Определения result.php:20