From 42e4f6d22f3c1f9b5b50210e02553f5ca7b5e195 Mon Sep 17 00:00:00 2001
From: Sanjeev Papnoi <sanjeev.papnoi829@webkul.com>
Date: Sat, 25 Jan 2020 17:01:47 +0530
Subject: [PATCH] updates

---
 CHANGELOG-1.0.md                               | 6 ++++++
 Controller/MailboxChannel.php                  | 5 ++---
 Resources/views/manageConfigurations.html.twig | 2 +-
 Services/MailboxService.php                    | 2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG-1.0.md b/CHANGELOG-1.0.md
index a288e40..dde52b9 100644
--- a/CHANGELOG-1.0.md
+++ b/CHANGELOG-1.0.md
@@ -3,6 +3,12 @@ CHANGELOG for 1.0.x
 
 This changelog references any relevant changes introduced in 1.0 minor versions.
 
+* 1.0.4 (2019-01-25)
+    * **Issue #38:** Issue for imap host field when add host inside qoutes ' '.
+    * **Issue #28:** Error while edit disable mailbox.
+    * **Issue #50:** Email setting are not being update in production mode.
+    * **Issue #51:** Duplicate entry for ticket when running refresh command second     time.
+
 * 1.0.3 (2019-11-15)
     * **Issue #46:** IMAP not creating tickets
     * **Misc. Updates:**
diff --git a/Controller/MailboxChannel.php b/Controller/MailboxChannel.php
index bb5d350..8611ce0 100644
--- a/Controller/MailboxChannel.php
+++ b/Controller/MailboxChannel.php
@@ -26,7 +26,7 @@ public function createMailboxConfiguration(Request $request)
 
             // IMAP Configuration
             if (!empty($params['imap']['transport'])) {
-                ($imapConfiguration = ImapConfiguration::createTransportDefinition($params['imap']['transport'], !empty($params['imap']['host']) ? $params['imap']['host'] : null))
+                ($imapConfiguration = ImapConfiguration::createTransportDefinition($params['imap']['transport'], !empty($params['imap']['host']) ? trim($params['imap']['host'], '"') : null))
                     ->setUsername($params['imap']['username'])
                     ->setPassword($params['imap']['password']);
             }
@@ -84,10 +84,9 @@ public function updateMailboxConfiguration($id, Request $request)
 
         if ($request->getMethod() == 'POST') {
             $params = $request->request->all();
-
             // IMAP Configuration
             if (!empty($params['imap']['transport'])) {
-                ($imapConfiguration = ImapConfiguration::createTransportDefinition($params['imap']['transport'], !empty($params['imap']['host']) ? $params['imap']['host'] : null))
+                ($imapConfiguration = ImapConfiguration::createTransportDefinition($params['imap']['transport'], !empty($params['imap']['host']) ? trim($params['imap']['host'], '"') : null))
                     ->setUsername($params['imap']['username'])
                     ->setPassword($params['imap']['password']);
             }
diff --git a/Resources/views/manageConfigurations.html.twig b/Resources/views/manageConfigurations.html.twig
index b17468f..cfaf357 100644
--- a/Resources/views/manageConfigurations.html.twig
+++ b/Resources/views/manageConfigurations.html.twig
@@ -124,7 +124,7 @@
 						<select name="swiftmailer_id" class="uv-select">
 							<option value="none">None Selected</option>
 							{% for configuration in swiftmailerConfigurations %}
-								{% if mailbox is defined and mailbox.swiftmailerConfiguration.id == configuration.id %}
+								{% if mailbox is defined and mailbox.swiftmailerConfiguration and mailbox.swiftmailerConfiguration.id == configuration.id %}
 									<option value="{{ configuration.id }}" selected>{{ configuration.id }}</option>
 								{% else %}
 									<option value="{{ configuration.id }}">{{ configuration.id }}</option>
diff --git a/Services/MailboxService.php b/Services/MailboxService.php
index 17b0631..9bb1595 100644
--- a/Services/MailboxService.php
+++ b/Services/MailboxService.php
@@ -337,7 +337,7 @@ public function processMail($rawEmail)
             ]);
 
             $this->container->get('event_dispatcher')->dispatch('uvdesk.automation.workflow.execute', $event);
-        } else if (false === $ticket->getIsTrashed() && strtolower($ticket->getStatus()->getCode()) != 'spam') {
+        } else if (false === $ticket->getIsTrashed() && strtolower($ticket->getStatus()->getCode()) != 'spam' && !empty($mailData['inReplyTo'])) {
             $mailData['threadType'] = 'reply';
             $thread = $this->entityManager->getRepository(Thread::class)->findOneByMessageId($mailData['messageId']);