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/rospirotorg.ru/bitrix/js/im/application/messenger/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/application/messenger/src/search.js
import { BaseEvent, EventEmitter } from 'main.core.events';
import { Item, Dialog } from "ui.entity-selector";
import { EventType } from 'im.const';

export class Search
{
	constructor(params = {}): void
	{
		if (typeof params.store === 'object' && params.store)
		{
			this.store = params.store;
		}

		this.dialog = new BX.UI.EntitySelector.Dialog({
			targetNode: params.targetNode,
			enableSearch: true,
			context: 'IM_CHAT_SEARCH',
			multiple: false,
			entities: [
				{
					id: 'user',
					filters: [
						{
							id: 'im.userDataFilter',
						},
					],
				},
				{
					id: 'department',
				},
				{
					id: 'im-chat',
					options: {
						searchableChatTypes: ['C', 'L', 'O',]
					}
				},
				{
					id: 'im-bot',
					options: {
						searchableBotTypes: ['H', 'B', 'S', 'N',]
					}
				},
			],
			events: {
				'Item:onSelect': (event: BaseEvent) => this.onItemSelect(event),
				'onLoad': (event: BaseEvent) => this.fillStore(event),
			}
		});
	}

	onItemSelect(event: BaseEvent): void
	{
		this.dialog.deselectAll();

		const item: Item = event.getData().item;

		const dialogId = this.getDialogIdByItem(item);
		if (!dialogId)
		{
			return;
		}

		EventEmitter.emit(EventType.dialog.open, { id: dialogId, $event: event });
	}

	fillStore(event: BaseEvent): void
	{
		const dialog: Dialog = event.getTarget();
		const items: Item[] = dialog.getItems();

		let users = [];
		let dialogues = [];

		items.forEach((item) => {
			const customData = item.getCustomData();
			const entityId = item.getEntityId();

			if (entityId === 'user' || entityId === 'im-bot')
			{
				const dialogId = customData.get('imUser')['ID'];
				if (!dialogId)
				{
					return;
				}

				users.push({
					dialogId,
					...customData.get('imUser'),
				});
			}
			else if (entityId === 'im-chat')
			{
				const dialogId = 'chat' + customData.get('imChat')['ID'];
				if (!dialogId)
				{
					return;
				}

				dialogues.push({
					dialogId,
					...customData.get('imChat'),
				});
			}
		});

		this.store.dispatch('users/set', users);
		this.store.dispatch('dialogues/set', dialogues);
	}

	getDialogIdByItem(item: Item): ?string
	{
		switch (item.getEntityId())
		{
			case 'user':
			case 'im-bot':
				return item.getCustomData().get('imUser')['ID'];
			case 'im-chat':
				return 'chat' + item.getCustomData().get('imChat')['ID'];
		}

		return null;
	}

	open(): void
	{
		this.dialog.show();
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit