58 return 'b_im_message';
70 'data_type' =>
'integer',
72 'autocomplete' =>
true,
76 'data_type' =>
'integer',
81 'data_type' =>
'integer',
86 'data_type' =>
'text',
88 'save_data_modification' => array(
'\Bitrix\Main\Text\Emoji',
'getSaveModificator'),
89 'fetch_data_modification' => array(
'\Bitrix\Main\Text\Emoji',
'getFetchModificator'),
91 'MESSAGE_OUT' => array(
92 'data_type' =>
'text',
94 'save_data_modification' => array(
'\Bitrix\Main\Text\Emoji',
'getSaveModificator'),
95 'fetch_data_modification' => array(
'\Bitrix\Main\Text\Emoji',
'getFetchModificator'),
97 'DATE_CREATE' => array(
98 'data_type' =>
'datetime',
101 'default_value' => array(__CLASS__,
'getCurrentDate'),
103 'EMAIL_TEMPLATE' => array(
104 'data_type' =>
'string',
105 'validation' => array(__CLASS__,
'validateEmailTemplate'),
108 'NOTIFY_TYPE' => array(
109 'data_type' =>
'integer',
112 'NOTIFY_MODULE' => array(
113 'data_type' =>
'string',
114 'validation' => array(__CLASS__,
'validateNotifyModule'),
117 'NOTIFY_EVENT' => array(
118 'data_type' =>
'string',
119 'validation' => array(__CLASS__,
'validateNotifyEvent'),
122 'NOTIFY_TAG' => array(
123 'data_type' =>
'string',
124 'validation' => array(__CLASS__,
'validateNotifyTag'),
127 'NOTIFY_SUB_TAG' => array(
128 'data_type' =>
'string',
129 'validation' => array(__CLASS__,
'validateNotifySubTag'),
132 'NOTIFY_TITLE' => array(
133 'data_type' =>
'string',
134 'validation' => array(__CLASS__,
'validateNotifyTitle'),
136 'save_data_modification' => array(
'\Bitrix\Main\Text\Emoji',
'getSaveModificator'),
137 'fetch_data_modification' => array(
'\Bitrix\Main\Text\Emoji',
'getFetchModificator'),
139 'NOTIFY_BUTTONS' => array(
140 'data_type' =>
'text',
143 'NOTIFY_READ' => array(
144 'data_type' =>
'boolean',
145 'values' => array(
'N',
'Y'),
148 'IMPORT_ID' => array(
149 'data_type' =>
'integer',
153 'data_type' =>
'Bitrix\Im\Model\ChatTable',
154 'reference' => array(
'=this.CHAT_ID' =>
'ref.ID'),
157 'data_type' =>
'Bitrix\Main\User',
158 'reference' => array(
'=this.AUTHOR_ID' =>
'ref.ID'),
161 'data_type' =>
'Bitrix\Im\Model\StatusTable',
162 'reference' => array(
'=this.AUTHOR_ID' =>
'ref.USER_ID'),
165 'data_type' =>
'Bitrix\Im\Model\RelationTable',
166 'reference' => array(
'=this.CHAT_ID' =>
'ref.CHAT_ID'),
167 'join_type' =>
'INNER',
170 'data_type' =>
'Bitrix\Im\Model\MessageIndex',
171 'reference' => array(
'=this.ID' =>
'ref.MESSAGE_ID'),
172 'join_type' =>
'INNER',
175 'data_type' => \
Bitrix\Im\Model\MessageUuidTable::class,
176 'reference' => array(
'=this.ID' =>
'ref.MESSAGE_ID'),
177 'join_type' =>
'LEFT',
189 new Main\
Entity\Validator\Length(
null, 255),
200 new Main\
Entity\Validator\Length(
null, 255),
211 new Main\
Entity\Validator\Length(
null, 255),
222 new Main\
Entity\Validator\Length(
null, 255),
233 new Main\
Entity\Validator\Length(
null, 255),
244 new Main\
Entity\Validator\Length(
null, 255),
255 return new \Bitrix\Main\Type\DateTime();
269 $indexEnabled = \Bitrix\Main\Config\Option::get(
'im',
'message_history_index');
276 $message = parent::getByPrimary($id)->fetch();
277 if (!is_array($message))
285 'SEARCH_CONTENT' => self::generateSearchContent($message)
299 private static function generateSearchContent(array $message) : string
301 $builder = MapBuilder::create();
303 if($message[
'AUTHOR_ID'] > 0)
305 $authorName = \Bitrix\Im\User::getInstance($message[
'AUTHOR_ID'])->getFullName();
306 $builder->addText($authorName);
309 $messageText = $message[
'MESSAGE'];
310 if($message[
'NOTIFY_TYPE'] === IM_NOTIFY_FROM)
312 $messageText = strip_tags($messageText);
314 else if($message[
'NOTIFY_TYPE'] === IM_NOTIFY_MESSAGE)
318 $builder->addText($messageText);
320 $params = \CIMMessageParam::Get($message[
'ID']);
322 if(isset($params[
'ATTACH']))
324 $textNodes = \CIMMessageParamAttach::GetTextForIndex($params[
'ATTACH'][0]);
325 foreach($textNodes as $text)
327 $builder->addText($text);
332 if(isset($params[
'FILE_ID']))
334 foreach($params[
'FILE_ID'] as $fileId)
336 $file = \Bitrix\Disk\File::getById($fileId);
341 $builder->addText($file->getName());
345 return $builder->build();
355 $whereSql = \Bitrix\Main\Entity\Query::buildFilterSql(static::getEntity(), $filter);
359 $tableName = static::getTableName();
360 $connection = Main\Application::getConnection();
361 $connection->queryExecute(
"DELETE FROM {$tableName} WHERE {$whereSql}");
371 $query->whereExpr(
"EXISTS ({$unreadSubQuery->getQuery()})", [
'ID']);
380 $query->whereExpr(
"EXISTS ({$viewedSubQuery->getQuery()})", [
'ID']);
389 $query->whereExpr(
"NOT EXISTS ({$unreadSubQuery->getQuery()})", [
'ID']);
static removeBbCodes($text, $withFile=false, $attachValue=false)