403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/cvetdv.ru/bitrix/js/im/v2/model/src/messages/format/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/js/im/v2/model/src/messages/format/field-config.js
import { Type } from 'main.core';

import { Utils } from 'im.v2.lib.utils';

import { convertToNumber, convertToString, isNumberOrString } from '../../utils/format';
import { prepareComponentId, prepareAuthorId, prepareKeyboard } from './format-functions';

import type { FieldsConfig } from '../../utils/validate';

export const messageFieldsConfig: FieldsConfig = [
	{
		fieldName: ['id', 'temporaryId'],
		targetFieldName: 'id',
		checkFunction: [Type.isNumber, Utils.text.isTempMessage],
	},
	{
		fieldName: 'chatId',
		targetFieldName: 'chatId',
		checkFunction: isNumberOrString,
		formatFunction: convertToNumber,
	},
	{
		fieldName: 'date',
		targetFieldName: 'date',
		checkFunction: [Type.isString, Type.isDate],
		formatFunction: Utils.date.cast,
	},
	{
		fieldName: 'text',
		targetFieldName: 'text',
		checkFunction: isNumberOrString,
		formatFunction: convertToString,
	},
	{
		fieldName: ['senderId', 'authorId'],
		targetFieldName: 'authorId',
		checkFunction: isNumberOrString,
		formatFunction: prepareAuthorId,
	},
	{
		fieldName: 'sending',
		targetFieldName: 'sending',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'unread',
		targetFieldName: 'unread',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'viewed',
		targetFieldName: 'viewed',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'viewedByOthers',
		targetFieldName: 'viewedByOthers',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'error',
		targetFieldName: 'error',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'componentId',
		targetFieldName: 'componentId',
		checkFunction: (target): boolean => {
			return Type.isString(target) && target !== '';
		},
		formatFunction: prepareComponentId,
	},
	{
		fieldName: 'componentParams',
		targetFieldName: 'componentParams',
		checkFunction: Type.isPlainObject,
	},
	{
		fieldName: ['files', 'fileId'],
		targetFieldName: 'files',
		checkFunction: Type.isArray,
	},
	{
		fieldName: 'attach',
		targetFieldName: 'attach',
		checkFunction: [Type.isArray, Type.isBoolean, Type.isString],
	},
	{
		fieldName: 'keyboard',
		targetFieldName: 'keyboard',
		checkFunction: Type.isArray,
		formatFunction: prepareKeyboard,
	},
	{
		fieldName: 'keyboard',
		targetFieldName: 'keyboard',
		checkFunction: (target): boolean => target === 'N',
		formatFunction: (): [] => [],
	},
	{
		fieldName: 'isEdited',
		targetFieldName: 'isEdited',
		checkFunction: Type.isString,
		formatFunction: (target): boolean => target === 'Y',
	},
	{
		fieldName: 'isEdited',
		targetFieldName: 'isEdited',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'isDeleted',
		targetFieldName: 'isDeleted',
		checkFunction: Type.isString,
		formatFunction: (target): boolean => target === 'Y',
	},
	{
		fieldName: 'isDeleted',
		targetFieldName: 'isDeleted',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'replyId',
		targetFieldName: 'replyId',
		checkFunction: isNumberOrString,
		formatFunction: convertToNumber,
	},
	{
		fieldName: 'forward',
		targetFieldName: 'forward',
		checkFunction: Type.isPlainObject,
	},
];

Youez - 2016 - github.com/yon3zu
LinuXploit