6use Bitrix\Im\Model\RelationTable;
7use Bitrix\Im\V2\Common\ActiveRecordImplementation;
8use Bitrix\Im\V2\Common\ContextCustomer;
9use Bitrix\Im\V2\Common\FieldAccessImplementation;
10use Bitrix\Im\V2\Common\RegistryEntryImplementation;
11use Bitrix\Im\V2\Entity\User\User;
12use Bitrix\Im\V2\Relation\Reason;
13use Bitrix\Im\V2\Rest\RestEntity;
14use Bitrix\Main\Type\DateTime;
18 use FieldAccessImplementation;
19 use ActiveRecordImplementation
23 use RegistryEntryImplementation;
26 protected ?
int $id =
null;
51 $this->initByDefault();
61 return $this->
getId();
66 return $this->
setId($primaryId);
71 return RelationTable::class;
76 if (isset($this->user))
96 ->setStartId($chat->getLastMessageId() + 1)
97 ->setLastFileId($chat->getLastFileId())
102 if (!$hideHistory && $chat->getContext()->getUserId() > 0)
104 $selfRelation = $chat->getSelfRelation();
105 if ($selfRelation !==
null && $selfRelation->getStartId() > 0)
108 ->setStartCounter($selfRelation->getStartId())
109 ->setLastFileId($selfRelation->getLastFileId())
110 ->setStartCounter($selfRelation->getStartCounter())
122 return (
new Result())->setData([
'SKIP_SAVE' =>
true]);
125 return $this->prepareFieldsDefault();
131 'id' => $this->
getId(),
135 'role' => mb_strtolower($this->
getRole()),
158 'set' =>
'setChatId',
159 'get' =>
'getChatId',
162 'field' =>
'messageType',
163 'set' =>
'setMessageType',
164 'get' =>
'getMessageType',
168 'set' =>
'setUserId',
169 'get' =>
'getUserId',
172 'field' =>
'startId',
173 'set' =>
'setStartId',
174 'get' =>
'getStartId',
177 'field' =>
'unreadId',
178 'set' =>
'setUnreadId',
179 'get' =>
'getUnreadId',
183 'set' =>
'setLastId',
184 'get' =>
'getLastId',
187 'field' =>
'lastSendId',
188 'set' =>
'setLastSendId',
189 'get' =>
'getLastSendId',
191 'LAST_SEND_MESSAGE_ID' => [
192 'field' =>
'lastSendMessageId',
193 'set' =>
'setLastSendMessageId',
194 'get' =>
'getLastSendMessageId',
197 'field' =>
'lastFileId',
198 'set' =>
'setLastFileId',
199 'get' =>
'getLastFileId',
202 'field' =>
'lastRead',
203 'set' =>
'setLastReadInternal',
204 'get' =>
'getLastRead',
208 'set' =>
'setStatus',
209 'get' =>
'getStatus',
212 'field' =>
'callStatus',
213 'set' =>
'setCallStatus',
214 'get' =>
'getCallStatus',
216 'MESSAGE_STATUS' => [
217 'field' =>
'messageStatus',
218 'set' =>
'setMessageStatus',
219 'get' =>
'getMessageStatus',
222 'field' =>
'notifyBlock',
223 'set' =>
'setNotifyBlock',
224 'get' =>
'getNotifyBlock',
227 'field' =>
'manager',
228 'set' =>
'setManager',
229 'get' =>
'getManager',
232 'field' =>
'counter',
233 'set' =>
'setCounter',
234 'get' =>
'getCounter',
237 'field' =>
'startCounter',
238 'set' =>
'setStartCounter',
239 'get' =>
'getStartCounter',
243 'set' =>
'setReason',
244 'get' =>
'getReason',
245 'loadFilter' =>
'prepareReasonForLoad',
246 'saveFilter' =>
'prepareReasonForSave',
249 'field' =>
'isHidden',
250 'set' =>
'markAsHidden',
271 return $this->chatId;
282 return $this->messageType;
304 return $this->startId;
315 return $this->unreadId;
337 return $this->lastSendId;
348 return $this->lastSendMessageId;
359 return $this->lastFileId;
370 return $this->lastRead;
379 private function setLastReadInternal($lastRead):
Relation
381 $lastReadDateTime =
null;
385 $lastReadDateTime = $lastRead;
387 elseif (!empty($lastRead))
389 $lastReadDateTime = DateTime::tryParse($lastRead) ?? DateTime::tryParse($lastRead,
'Y-m-d H:i:s');
392 return $this->setLastRead($lastReadDateTime);
408 return $this->callStatus;
419 return $this->messageStatus;
430 return $this->notifyBlock;
463 return $this->startCounter;
474 return $this->reason;
486 return Reason::tryFrom(
$reason) ?? Reason::DEFAULT;
496 return $this->isHidden;
509 return Chat::ROLE_GUEST;
513 return Chat::ROLE_MANAGER;
517 return Chat::ROLE_OWNER;
520 return Chat::ROLE_MEMBER;
525 $this->isFake =
true;
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getMessageCount($chatId, $userId=null)
static getInstance($userId=null)
static getRestEntityName()
setPrimaryId(int $primaryId)
setMessageStatus(?string $messageStatus)
setManager(?bool $manager)
toRestFormat(array $option=[])
setLastRead(?DateTime $lastRead)
setMessageType(?string $messageType)
setLastSendId(?int $lastSendId)
setReason(Reason $reason)
setStartId(?int $startId)
__construct($source=null)
prepareReasonForSave(Reason $reason)
setNotifyBlock(?bool $notifyBlock)
prepareReasonForLoad(string $reason)
setStartCounter(?int $startCounter)
setCounter(?int $counter)
setLastFileId(?int $lastFileId)
setLastSendMessageId(?int $lastSendMessageId)
setCallStatus(?int $callStatus)
setUnreadId(?int $unreadId)
fillRestriction(bool $hideHistory, Chat $chat)
markAsHidden(?bool $isHidden)
static mirrorDataEntityFields()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)