@@ -106,7 +106,10 @@ public function parseMailboxConfigurations(bool $ignoreInvalidAttributes = false
106106 // SMTP Configuration
107107 $ smtpConfiguration = null ;
108108
109- if (!empty ($ params ['smtp_server ' ]) && !isset ($ params ['smtp_server ' ]['mailer_id ' ])) {
109+ if (
110+ ! empty ($ params ['smtp_server ' ])
111+ && !isset ($ params ['smtp_server ' ]['mailer_id ' ])
112+ ) {
110113 $ smtpConfiguration = SMTP \Configuration::guessTransportDefinition ($ params ['smtp_server ' ]);
111114
112115 if ($ smtpConfiguration instanceof SMTP \Transport \AppTransportConfigurationInterface) {
@@ -127,7 +130,7 @@ public function parseMailboxConfigurations(bool $ignoreInvalidAttributes = false
127130 ->setPassword ($ params ['smtp_server ' ]['password ' ])
128131 ;
129132
130- if (!empty ($ params ['smtp_server ' ]['sender_address ' ])) {
133+ if (! empty ($ params ['smtp_server ' ]['sender_address ' ])) {
131134 $ smtpConfiguration
132135 ->setSenderAddress ($ params ['smtp_server ' ]['sender_address ' ])
133136 ;
@@ -140,13 +143,13 @@ public function parseMailboxConfigurations(bool $ignoreInvalidAttributes = false
140143 ->setName ($ params ['name ' ])
141144 ->setIsEnabled ($ params ['enabled ' ]);
142145
143- if (!empty ($ imapConfiguration )) {
146+ if (! empty ($ imapConfiguration )) {
144147 $ mailbox
145148 ->setImapConfiguration ($ imapConfiguration )
146149 ;
147150 }
148151
149- if (!empty ($ smtpConfiguration )) {
152+ if (! empty ($ smtpConfiguration )) {
150153 $ mailbox
151154 ->setSmtpConfiguration ($ smtpConfiguration )
152155 ;
@@ -280,8 +283,8 @@ private function searchTicketSubjectReference($senderEmail, $messageSubject) {
280283
281284 // Search Criteria: Find ticket based on subject
282285 if (
283- !empty ($ senderEmail )
284- && !empty ($ messageSubject )
286+ ! empty ($ senderEmail )
287+ && ! empty ($ messageSubject )
285288 ) {
286289 $ threadRepository = $ this ->entityManager ->getRepository (Thread::class);
287290 $ ticket = $ threadRepository ->findTicketBySubject ($ senderEmail , $ messageSubject );
@@ -318,7 +321,7 @@ private function searchExistingTickets(array $criterias = [])
318321 } else {
319322 $ thread = $ threadRepository ->findOneByMessageId ($ criteriaValue );
320323
321- if (!empty ($ thread )) {
324+ if (! empty ($ thread )) {
322325 return $ thread ->getTicket ();
323326 }
324327 }
@@ -377,10 +380,10 @@ public function processMail($rawEmail)
377380
378381 $ from = $ this ->parseAddress ('from ' ) ?: $ this ->parseAddress ('sender ' );
379382 $ addresses = [
380- 'from ' => $ this ->getEmailAddress ($ from ),
381- 'to ' => empty ($ this ->parseAddress ('X-Forwarded-To ' )) ? $ this ->parseAddress ('to ' ) : $ this ->parseAddress ('X-Forwarded-To ' ),
382- 'cc ' => $ this ->parseAddress ('cc ' ),
383- 'delivered-to ' => $ this ->parseAddress ('delivered-to ' ),
383+ 'from ' => $ this ->getEmailAddress ($ from ),
384+ 'to ' => empty ($ this ->parseAddress ('X-Forwarded-To ' )) ? $ this ->parseAddress ('to ' ) : $ this ->parseAddress ('X-Forwarded-To ' ),
385+ 'cc ' => $ this ->parseAddress ('cc ' ),
386+ 'delivered-to ' => $ this ->parseAddress ('delivered-to ' ),
384387 ];
385388
386389 if (empty ($ addresses ['from ' ])) {
@@ -468,7 +471,7 @@ public function processMail($rawEmail)
468471 $ mailData ['subject ' ] = $ parser ->getHeader ('subject ' );
469472 $ mailData ['message ' ] = autolink ($ htmlFilter ->addClassEmailReplyQuote ($ parser ->getMessageBody ('htmlEmbedded ' )));
470473 $ mailData ['attachments ' ] = $ parser ->getAttachments ();
471- }catch (\Exception $ e ){
474+ } catch (\Exception $ e ) {
472475 return [
473476 'error ' => true ,
474477 'message ' => $ e ->getMessage (),
@@ -481,7 +484,7 @@ public function processMail($rawEmail)
481484
482485 $ website = $ this ->entityManager ->getRepository (Website::class)->findOneByCode ('knowledgebase ' );
483486
484- if (!empty ($ mailData ['from ' ]) && $ this ->container ->get ('ticket.service ' )->isEmailBlocked ($ mailData ['from ' ], $ website )) {
487+ if (! empty ($ mailData ['from ' ]) && $ this ->container ->get ('ticket.service ' )->isEmailBlocked ($ mailData ['from ' ], $ website )) {
485488 return [
486489 'message ' => "Received email where the sender email address is present in the block list. Skipping this email from further processing. " ,
487490 'content ' => [
@@ -530,7 +533,7 @@ public function processMail($rawEmail)
530533 return [
531534 'message ' => "The contents of this email has already been processed. " ,
532535 'content ' => [
533- 'from ' => !empty ($ mailData ['from ' ]) ? $ mailData ['from ' ] : null ,
536+ 'from ' => ! empty ($ mailData ['from ' ]) ? $ mailData ['from ' ] : null ,
534537 'thread ' => $ thread ->getId (),
535538 'ticket ' => $ ticket ->getId (),
536539 ],
@@ -547,13 +550,16 @@ public function processMail($rawEmail)
547550 ];
548551 }
549552
550- if ($ ticket ->getCustomer () && $ ticket ->getCustomer ()->getEmail () == $ mailData ['from ' ]) {
553+ if (
554+ $ ticket ->getCustomer ()
555+ && $ ticket ->getCustomer ()->getEmail () == $ mailData ['from ' ]
556+ ) {
551557 // Reply from customer
552558 $ user = $ ticket ->getCustomer ();
553559
554560 $ mailData ['user ' ] = $ user ;
555561 $ userDetails = $ user ->getCustomerInstance ()->getPartialDetails ();
556- } else if ($ this ->entityManager ->getRepository (Ticket::class)->isTicketCollaborator ($ ticket , $ mailData ['from ' ])){
562+ } else if ($ this ->entityManager ->getRepository (Ticket::class)->isTicketCollaborator ($ ticket , $ mailData ['from ' ])) {
557563 // Reply from collaborator
558564 $ user = $ this ->entityManager ->getRepository (User::class)->findOneByEmail ($ mailData ['from ' ]);
559565
@@ -563,7 +569,10 @@ public function processMail($rawEmail)
563569 } else {
564570 $ user = $ this ->entityManager ->getRepository (User::class)->findOneByEmail ($ mailData ['from ' ]);
565571
566- if (!empty ($ user ) && null != $ user ->getAgentInstance ()) {
572+ if (
573+ ! empty ($ user )
574+ && null != $ user ->getAgentInstance ()
575+ ) {
567576 $ mailData ['user ' ] = $ user ;
568577 $ mailData ['createdBy ' ] = 'agent ' ;
569578 $ userDetails = $ user ->getAgentInstance ()->getPartialDetails ();
@@ -589,7 +598,6 @@ public function processMail($rawEmail)
589598 $ this ->entityManager ->flush ();
590599
591600 $ ticket ->lastCollaborator = $ user ;
592-
593601
594602 $ event = new CoreWorkflowEvents \Ticket \Collaborator ();
595603 $ event
@@ -780,18 +788,22 @@ public function processOutlookMail(array $outlookEmail)
780788 ;
781789
782790 $ this ->container ->get ('event_dispatcher ' )->dispatch ($ event , 'uvdesk.automation.workflow.execute ' );
783- } else if (false === $ ticket ->getIsTrashed () && strtolower ($ ticket ->getStatus ()->getCode ()) != 'spam ' && !empty ($ mailData ['inReplyTo ' ])) {
791+ } else if (
792+ false === $ ticket ->getIsTrashed ()
793+ && strtolower ($ ticket ->getStatus ()->getCode ()) != 'spam '
794+ && ! empty ($ mailData ['inReplyTo ' ])
795+ ) {
784796 $ mailData ['threadType ' ] = 'reply ' ;
785797 $ thread = $ this ->entityManager ->getRepository (Thread::class)->findOneByMessageId ($ mailData ['messageId ' ]);
786798 $ ticketRef = $ this ->entityManager ->getRepository (Ticket::class)->findById ($ ticket ->getId ());
787799 $ referenceIds = explode (' ' , $ ticketRef [0 ]->getReferenceIds ());
788800
789- if (!empty ($ thread )) {
801+ if (! empty ($ thread )) {
790802 // Thread with the same message id exists skip process.
791803 return [
792804 'message ' => "The contents of this email has already been processed 1. " ,
793805 'content ' => [
794- 'from ' => !empty ($ mailData ['from ' ]) ? $ mailData ['from ' ] : null ,
806+ 'from ' => ! empty ($ mailData ['from ' ]) ? $ mailData ['from ' ] : null ,
795807 'thread ' => $ thread ->getId (),
796808 'ticket ' => $ ticket ->getId (),
797809 ],
@@ -823,8 +835,7 @@ public function processOutlookMail(array $outlookEmail)
823835 $ userDetails = $ user ->getCustomerInstance ()->getPartialDetails ();
824836 } else {
825837 $ user = $ this ->entityManager ->getRepository (User::class)->findOneByEmail ($ mailData ['from ' ]);
826-
827- if (!empty ($ user ) && null != $ user ->getAgentInstance ()) {
838+ if (! empty ($ user ) && null != $ user ->getAgentInstance ()) {
828839 $ mailData ['user ' ] = $ user ;
829840 $ mailData ['createdBy ' ] = 'agent ' ;
830841 $ userDetails = $ user ->getAgentInstance ()->getPartialDetails ();
@@ -865,7 +876,7 @@ public function processOutlookMail(array $outlookEmail)
865876
866877 $ thread = $ this ->container ->get ('ticket.service ' )->createThread ($ ticket , $ mailData );
867878
868- if ($ thread ->getThreadType () == 'reply ' ) {
879+ if ($ thread ->getThreadType () == 'reply ' ) {
869880 if ($ thread ->getCreatedBy () == 'customer ' ) {
870881 $ event = new CoreWorkflowEvents \Ticket \CustomerReply ();
871882 $ event
0 commit comments