- Модуль: rpa
- Путь к файлу: ~/bitrix/modules/rpa/lib/controller/comment.php
- Класс: BitrixRpaControllerComment
- Вызов: Comment::updateAction
public function updateAction(int $id, array $fields, string $eventId = ''): ?array
{
$timeline = TimelineTable::getById($id)->fetchObject();
if(!$timeline)
{
$this->addError(new Error(Loc::getMessage('RPA_COMMENT_NOT_FOUND_ERROR')));
return null;
}
$userPermissions = Driver::getInstance()->getUserPermissions();
if(!$userPermissions->canUpdateComment($timeline))
{
$this->addError(new Error(Loc::getMessage('RPA_MODIFY_COMMENT_ACCESS_DENIED')));
return null;
}
$emptyFields = $this->getEmptyRequiredParameterNames($fields, ['description']);
if(!empty($emptyFields))
{
$this->addError(new Error('Empty required fields: '.implode(', ', $emptyFields)));
return null;
}
$uiComment = static::getUiComment();
$previouslyMentionedUserIds = static::getCommentParser()->getMentionedUserIds($timeline->getDescription());
$timeline->setDescription($fields['description']);
$files = $this->processFiles($fields);
$result = $timeline->save();
if($result->isSuccess())
{
$uiComment->saveFiles($timeline->getId(), $files);
$this->sendMentions($timeline, $previouslyMentionedUserIds);
Driver::getInstance()->getPullManager()->sendTimelineUpdateEvent($timeline, $eventId);
return [
'comment' => $timeline->preparePublicData(),
];
}
$this->addErrors($result->getErrors());
return null;
}