3namespace Bitrix\Im\V2\Message\Reaction;
5use Bitrix\Im\Model\ReactionTable;
6use Bitrix\Im\V2\ActiveRecord;
7use Bitrix\Im\V2\Common\ActiveRecordImplementation;
8use Bitrix\Im\V2\Common\ContextCustomer;
9use Bitrix\Im\V2\Common\RegistryEntryImplementation;
10use Bitrix\Im\V2\Entity\User\UserPopupItem;
11use Bitrix\Im\V2\RegistryEntry;
12use Bitrix\Im\V2\Rest\PopupData;
13use Bitrix\Im\V2\Rest\PopupDataAggregatable;
14use Bitrix\Im\V2\Rest\RestConvertible;
15use Bitrix\Im\V2\Result;
16use Bitrix\Main\Localization\Loc;
17use Bitrix\Main\Type\DateTime;
22 use RegistryEntryImplementation;
23 use ActiveRecordImplementation;
25 public const LIKE =
'LIKE';
26 public const KISS =
'KISS';
29 public const CRY =
'CRY';
45 private int $messageId;
47 private string $reaction;
52 $this->initByDefault();
60 public static function getByMessage(
int $messageId,
string $reaction,
int $userId): ?self
62 $reactionObject = ReactionTable::query()
64 ->where(
'MESSAGE_ID', $messageId)
65 ->where(
'REACTION', $reaction)
66 ->where(
'USER_ID', $userId)
70 if ($reactionObject ===
null)
75 return new static($reactionObject);
83 public function getLocName(?
string $languageId =
null): ?string
85 return Loc::getMessage(
"IM_MESSAGE_REACTION_NAME_{$this->reaction}_MSGVER_1",
null, $languageId);
90 return $this->
id ??
null;
95 $this->
id = $primaryId;
102 return $this->chatId;
107 $this->chatId = $chatId;
118 $this->messageId = $messageId;
129 $this->userId = $userId;
135 return $this->reaction;
140 $this->reaction = $reaction;
146 return $this->dateCreate;
151 $this->dateCreate = $dateCreate;
162 return static::validateReaction($this->reaction);
174 if (!in_array($reaction, self::ALLOWED_REACTION,
true))
191 'set' =>
'setPrimaryId',
192 'get' =>
'getPrimaryId',
196 'set' =>
'setChatId',
197 'get' =>
'getChatId',
200 'field' =>
'messageId',
201 'set' =>
'setMessageId',
202 'get' =>
'getMessageId',
206 'set' =>
'setUserId',
207 'get' =>
'getUserId',
210 'field' =>
'reaction',
211 'set' =>
'setReaction',
212 'get' =>
'getReaction',
213 'default' =>
'getDefaultReaction',
214 'beforeSave' =>
'beforeSaveReaction',
217 'field' =>
'dateCreate',
218 'get' =>
'getDateCreate',
219 'set' =>
'setDateCreate',
220 'default' =>
'getDefaultDateCreate',
227 return ReactionTable::class;
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getRestEntityName()
setPrimaryId(int $primaryId)
toRestFormat(array $option=[])
getLocName(?string $languageId=null)
getPopupData(array $excludedList=[])
__construct($source=null)
static getByMessage(int $messageId, string $reaction, int $userId)
setMessageId(int $messageId)
static validateReaction(string $reaction)
setReaction(string $reaction)
setDateCreate(DateTime $dateCreate)
static mirrorDataEntityFields()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)