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/chats/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/chats/format/field-config.js
import { Utils } from 'im.v2.lib.utils';
import { Type } from 'main.core';
import { convertToNumber, convertToString, isNumberOrString } from '../../utils/format';
import { formatFieldsWithConfig, type FieldsConfig } from 'im.v2.model';
import {
	prepareAvatar,
	prepareChatName,
	prepareLastMessageViews,
	prepareManagerList,
	prepareMuteList,
} from './format-functions';

export const chatFieldsConfig: FieldsConfig = [
	{
		fieldName: 'dialogId',
		targetFieldName: 'dialogId',
		checkFunction: isNumberOrString,
		formatFunction: convertToString,
	},
	{
		fieldName: ['id', 'chatId'],
		targetFieldName: 'chatId',
		checkFunction: isNumberOrString,
		formatFunction: convertToNumber,
	},
	{
		fieldName: 'type',
		targetFieldName: 'type',
		checkFunction: Type.isString,
	},
	{
		fieldName: 'quoteId',
		targetFieldName: 'quoteId',
		checkFunction: Type.isNumber,
	},
	{
		fieldName: 'counter',
		targetFieldName: 'counter',
		checkFunction: isNumberOrString,
		formatFunction: convertToNumber,
	},
	{
		fieldName: 'userCounter',
		targetFieldName: 'userCounter',
		checkFunction: isNumberOrString,
		formatFunction: convertToNumber,
	},
	{
		fieldName: 'lastId',
		targetFieldName: 'lastReadId',
		checkFunction: Type.isNumber,
	},
	{
		fieldName: 'markedId',
		targetFieldName: 'markedId',
		checkFunction: Type.isNumber,
	},
	{
		fieldName: 'lastMessageId',
		targetFieldName: 'lastMessageId',
		checkFunction: isNumberOrString,
		formatFunction: convertToNumber,
	},
	{
		fieldName: 'lastMessageViews',
		targetFieldName: 'lastMessageViews',
		checkFunction: Type.isPlainObject,
		formatFunction: prepareLastMessageViews,
	},
	{
		fieldName: 'hasPrevPage',
		targetFieldName: 'hasPrevPage',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'hasNextPage',
		targetFieldName: 'hasNextPage',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'savedPositionMessageId',
		targetFieldName: 'savedPositionMessageId',
		checkFunction: Type.isNumber,
	},
	{
		fieldName: ['title', 'name'],
		targetFieldName: 'name',
		checkFunction: isNumberOrString,
		formatFunction: prepareChatName,
	},
	{
		fieldName: ['owner', 'ownerId'],
		targetFieldName: 'ownerId',
		checkFunction: isNumberOrString,
		formatFunction: convertToNumber,
	},
	{
		fieldName: 'avatar',
		targetFieldName: 'avatar',
		checkFunction: Type.isString,
		formatFunction: prepareAvatar,
	},
	{
		fieldName: 'color',
		targetFieldName: 'color',
		checkFunction: Type.isString,
	},
	{
		fieldName: 'extranet',
		targetFieldName: 'extranet',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'containsCollaber',
		targetFieldName: 'containsCollaber',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'entityLink',
		targetFieldName: 'entityLink',
		checkFunction: Type.isPlainObject,
		formatFunction: (target) => {
			return formatFieldsWithConfig(target, chatEntityFieldsConfig);
		},
	},
	{
		fieldName: 'dateCreate',
		targetFieldName: 'dateCreate',
		formatFunction: Utils.date.cast,
	},
	{
		fieldName: 'public',
		targetFieldName: 'public',
		checkFunction: Type.isPlainObject,
	},
	{
		fieldName: 'inputActionList',
		targetFieldName: 'inputActionList',
		checkFunction: Type.isPlainObject,
	},
	{
		fieldName: 'managerList',
		targetFieldName: 'managerList',
		checkFunction: Type.isArray,
		formatFunction: prepareManagerList,
	},
	{
		fieldName: 'muteList',
		targetFieldName: 'muteList',
		checkFunction: [Type.isArray, Type.isPlainObject],
		formatFunction: prepareMuteList,
	},
	{
		fieldName: 'inited',
		targetFieldName: 'inited',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'loading',
		targetFieldName: 'loading',
		checkFunction: Type.isBoolean,
	},
	{
		fieldName: 'description',
		targetFieldName: 'description',
		checkFunction: Type.isString,
	},
	{
		fieldName: 'diskFolderId',
		targetFieldName: 'diskFolderId',
		checkFunction: Type.isNumber,
	},
	{
		fieldName: 'role',
		targetFieldName: 'role',
		checkFunction: Type.isString,
		formatFunction: (target: string) => target.toLowerCase(),
	},
	{
		fieldName: 'permissions',
		targetFieldName: 'permissions',
		checkFunction: Type.isPlainObject,
	},
	{
		fieldName: 'tariffRestrictions',
		targetFieldName: 'tariffRestrictions',
		checkFunction: Type.isPlainObject,
	},
	{
		fieldName: 'parentChatId',
		targetFieldName: 'parentChatId',
		checkFunction: Type.isNumber,
	},
	{
		fieldName: 'backgroundId',
		targetFieldName: 'backgroundId',
		checkFunction: Type.isString,
	},
	{
		fieldName: 'textFieldEnabled',
		targetFieldName: 'isTextareaEnabled',
		checkFunction: Type.isBoolean,
	},
];

export const chatEntityFieldsConfig = [
	{
		fieldName: 'type',
		targetFieldName: 'type',
		checkFunction: Type.isString,
	},
	{
		fieldName: 'url',
		targetFieldName: 'url',
		checkFunction: Type.isString,
	},
];

Youez - 2016 - github.com/yon3zu
LinuXploit