@@ -86,6 +86,7 @@ public function parseMailboxConfigurations(bool $ignoreInvalidAttributes = false
8686 ($ mailbox = new Mailbox ($ id ))
8787 ->setName ($ params ['name ' ])
8888 ->setIsEnabled ($ params ['enabled ' ])
89+ ->setIsDeleted (empty ($ params ['deleted ' ]) ? false : $ params ['deleted ' ])
8990 ->setImapConfiguration ($ imapConfiguration );
9091
9192 if (!empty ($ swiftmailerConfiguration )) {
@@ -160,7 +161,7 @@ public function getEmailAddress($addresses)
160161 public function getMailboxByEmail ($ email )
161162 {
162163 foreach ($ this ->getRegisteredMailboxes () as $ registeredMailbox ) {
163- if ($ email === $ registeredMailbox ['imap_server ' ]['username ' ]) {
164+ if (strtolower ( $ email) === strtolower ( $ registeredMailbox ['imap_server ' ]['username ' ]) ) {
164165 return $ registeredMailbox ;
165166 }
166167 }
@@ -171,7 +172,7 @@ public function getMailboxByEmail($email)
171172 public function getMailboxByToEmail ($ email )
172173 {
173174 foreach ($ this ->getRegisteredMailboxes () as $ registeredMailbox ) {
174- if ($ email === $ registeredMailbox ['imap_server ' ]['username ' ]) {
175+ if (strtolower ( $ email) === strtolower ( $ registeredMailbox ['imap_server ' ]['username ' ]) ) {
175176 return true ;
176177 }
177178 }
@@ -385,7 +386,7 @@ public function processMail($rawEmail)
385386 $ thread = $ this ->entityManager ->getRepository (Thread::class)->findOneByMessageId ($ mailData ['messageId ' ]);
386387
387388 if (!empty ($ thread )) {
388- // Thread with the same message id exists. Skip processing .
389+ // Thread with the same message id exists skip process .
389390 return ;
390391 }
391392
@@ -395,6 +396,13 @@ public function processMail($rawEmail)
395396
396397 $ mailData ['user ' ] = $ user ;
397398 $ userDetails = $ user ->getCustomerInstance ()->getPartialDetails ();
399+ } else if ($ this ->entityManager ->getRepository (Ticket::class)->isTicketCollaborator ($ ticket , $ mailData ['from ' ])){
400+ // Reply from collaborator
401+ $ user = $ this ->entityManager ->getRepository (User::class)->findOneByEmail ($ mailData ['from ' ]);
402+
403+ $ mailData ['user ' ] = $ user ;
404+ $ mailData ['createdBy ' ] = 'collaborator ' ;
405+ $ userDetails = $ user ->getCustomerInstance ()->getPartialDetails ();
398406 } else {
399407 $ user = $ this ->entityManager ->getRepository (User::class)->findOneByEmail ($ mailData ['from ' ]);
400408
@@ -443,6 +451,10 @@ public function processMail($rawEmail)
443451 $ event = new GenericEvent (CoreWorkflowEvents \Ticket \CustomerReply::getId (), [
444452 'entity ' => $ ticket ,
445453 ]);
454+ } else if ($ thread ->getCreatedBy () == 'collaborator ' ) {
455+ $ event = new GenericEvent (CoreWorkflowEvents \Ticket \CollaboratorReply::getId (), [
456+ 'entity ' => $ ticket ,
457+ ]);
446458 } else {
447459 $ event = new GenericEvent (CoreWorkflowEvents \Ticket \AgentReply::getId (), [
448460 'entity ' => $ ticket ,
@@ -456,4 +468,4 @@ public function processMail($rawEmail)
456468
457469 return ;
458470 }
459- }
471+ }
0 commit comments