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