1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
UpdateChatHandler.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Socialnetwork\Collab\Converter\Handler;
6
7use Bitrix\Main\Error;
8use Bitrix\Main\Result;
9use Bitrix\Socialnetwork\Collab\Converter\Command\AbstractConverterCommand;
10use Bitrix\Socialnetwork\Collab\Integration\IM\ChatType;
11use Bitrix\Socialnetwork\Collab\Integration\IM\Messenger;
12use Bitrix\Socialnetwork\Integration\Im\ChatFactory;
13use Bitrix\Socialnetwork\Internals\Registry\GroupRegistry;
14use Bitrix\Socialnetwork\Item\Workgroup;
15use Bitrix\Socialnetwork\Item\Workgroup\Type;
16
18{
19 public function execute(AbstractConverterCommand $command): Result
20 {
21 $result = new Result();
22 $group = GroupRegistry::getInstance()->get($command->getGroup()->getId());
23
24 $type = $group->getType();
25 $chatId = $group->getChatId();
26
27 if (!$type instanceof Type)
28 {
29 return $result->addError(new Error('Incorrect group type'));
30 }
31
32 if ($chatId <= 0)
33 {
34 return $result->addError(new Error('Group has no chat'));
35 }
36
37 $fields = $this->prepareChatFields($group);
38 $updateService = Messenger::getUpdateService($group->getChatId(), $fields);
39
40 if (!$updateService)
41 {
42 return $result->addError(new Error('Chat update service not found'));
43 }
44
45 $chatUpdateResult = $updateService->updateChat();
46
47 if (!$chatUpdateResult->isSuccess())
48 {
49 return $result->addErrors($chatUpdateResult->getErrors());
50 }
51
52 return $result;
53 }
54
55 private function prepareChatFields(Workgroup $group): array
56 {
57 $type = $group->getType();
58 $fields = ChatFactory::getUniqueFieldsByType($type);
59 $fields['TITLE'] = ChatFactory::getChatTitle($group->getName(), $type);
61
62 return $fields;
63 }
64}
$type
Определения options.php:106
Определения error.php:15
execute(AbstractConverterCommand $command)
Определения UpdateChatHandler.php:19
static getChatTypeByGroupType(Type $type)
Определения ChatType.php:12
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
Определения collection.php:2
$fields
Определения yandex_run.php:501