getRequest()->getParam('thread_id'); $orderId = (int)$this->getRequest()->getParam('order_id'); $redirect = $this->resultRedirectFactory->create(); if (!$this->formKey->validate($this->getRequest())) { $this->messageManager->addErrorMessage(__('Your session has expired. Please try again.')); return $redirect->setPath('esun_customer_message/message/index', $threadId ? ['thread_id' => $threadId] : ['order_id' => $orderId]); } try { $threadId = $this->conversations->sendAsAdmin( (int)$this->_auth->getUser()->getId(), (string)$this->getRequest()->getParam('content'), (array)$this->getRequest()->getFiles('images', []), $threadId, $orderId ); $this->messageManager->addSuccessMessage(__('The reply has been sent.')); } catch (\Throwable $exception) { $this->messageManager->addErrorMessage($exception instanceof \Magento\Framework\Exception\LocalizedException ? $exception->getMessage() : __('The reply could not be sent.')); } return $redirect->setPath('esun_customer_message/message/index', ['thread_id' => $threadId]); } }