Skip to content

Commit 07f67cf

Browse files
author
akshay kumar
committed
Merge branch '1.0' of https://github.com/uvdesk/mailbox-component into HEAD
2 parents f71a0ea + 64e0260 commit 07f67cf

8 files changed

+113
-38
lines changed

.github/ISSUE_TEPLATES/Bug_report.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: 🐛 Bug Report
3+
about: Report errors and problems
4+
5+
---
6+
7+
**Description**
8+
<!-- A clear and concise description of the problem. -->
9+
10+
**How to reproduce**
11+
<!-- Code and/or config needed to reproduce the problem. -->
12+
13+
**Possible Solution**
14+
<!--- Optional: only if you have suggestions on a fix/reason for the bug -->
15+
16+
**Additional context**
17+
<!-- Optional: any other context about the problem: log messages, screenshots, etc. -->
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: 🚀 Feature Request
3+
about: RFC and ideas for new features and improvements
4+
5+
---
6+
7+
**Description**
8+
<!-- A clear and concise description of the new feature. -->
9+
10+
**Example**
11+
<!-- A simple example of the new feature in action (include PHP code, YAML config, etc.)
12+
If the new feature changes an existing feature, include a simple before/after comparison. -->
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: ⛔ Support Question
3+
about: Visit https://support.uvdesk.com/ to learn more about how the uvdesk team can assist you
4+
5+
---
6+
7+
We use GitHub issues only to discuss about uvdesk bugs and new features. For customizations and extended support:
8+
9+
- Contact us at [email protected]
10+
- Visit official support website (https://support.uvdesk.com/en/)
11+
- Visit our community forums (https://forums.uvdesk.com)
12+
13+
Thanks!

.github/PULL_REQUEST_TEMPLATE.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
Thank you for contributing to UVDesk! Please fill out this description template to help us to process your pull request.
3+
-->
4+
5+
### 1. Why is this change necessary?
6+
7+
8+
### 2. What does this change do, exactly?
9+
10+
11+
### 3. Please link to the relevant issues (if any).

.github/SECURITY.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Security Policy
2+
===============
3+
4+
⚠ PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, SEE BELOW.
5+
6+
If you have found a security issue in Uvdesk, please send the details to [email protected] and don't disclose it publicly until we can provide a fix for it.
7+
8+
Thanks!

CHANGELOG-1.0.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ CHANGELOG for 1.0.x
33

44
This changelog references any relevant changes introduced in 1.0 minor versions.
55

6+
* 1.0.3 (2019-11-15)
7+
* **Issue #46:** IMAP not creating tickets
8+
* **Misc. Updates:**
9+
* Included Github issue templates
10+
* Updated composer dependencies & set minimum required php version to 7.2
11+
612
* 1.0.2 (2019-10-22)
713
* **Misc. Updates:**
814
* Use https when available while refreshing mailboxes via CLI

Services/MailboxService.php

+45-37
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
use Doctrine\ORM\EntityManagerInterface;
88
use Symfony\Component\HttpFoundation\Request;
99
use Symfony\Component\HttpFoundation\Response;
10-
use Webkul\UVDesk\CoreFrameworkBundle\Utils\HTMLFilter;
11-
use Webkul\UVDesk\CoreFrameworkBundle\Utils\TokenGenerator;
1210
use Symfony\Component\HttpFoundation\RequestStack;
11+
use Webkul\UVDesk\CoreFrameworkBundle\Entity\User;
1312
use Symfony\Component\EventDispatcher\GenericEvent;
14-
use Symfony\Component\DependencyInjection\ContainerInterface;
15-
use Webkul\UVDesk\CoreFrameworkBundle\Workflow\Events as CoreWorkflowEvents;
13+
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Ticket;
14+
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Thread;
15+
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Website;
1616
use Webkul\UVDesk\MailboxBundle\Utils\Mailbox\Mailbox;
17+
use Webkul\UVDesk\CoreFrameworkBundle\Utils\HTMLFilter;
18+
use Webkul\UVDesk\CoreFrameworkBundle\Entity\SupportRole;
19+
use Webkul\UVDesk\CoreFrameworkBundle\Utils\TokenGenerator;
1720
use Webkul\UVDesk\MailboxBundle\Utils\MailboxConfiguration;
21+
use Symfony\Component\DependencyInjection\ContainerInterface;
22+
use Webkul\UVDesk\CoreFrameworkBundle\Workflow\Events as CoreWorkflowEvents;
1823
use Webkul\UVDesk\MailboxBundle\Utils\Imap\Configuration as ImapConfiguration;
1924

2025
class MailboxService
@@ -166,8 +171,8 @@ private function searchExistingTickets(array $criterias = [])
166171
return null;
167172
}
168173

169-
$ticketRepository = $this->entityManager->getRepository('UVDeskCoreFrameworkBundle:Ticket');
170-
$threadRepository = $this->entityManager->getRepository('UVDeskCoreFrameworkBundle:Thread');
174+
$ticketRepository = $this->entityManager->getRepository(Ticket::class);
175+
$threadRepository = $this->entityManager->getRepository(Thread::class);
171176

172177
foreach ($criterias as $criteria => $criteriaValue) {
173178
if (empty($criteriaValue)) {
@@ -271,7 +276,7 @@ public function processMail($rawEmail)
271276
return;
272277
}
273278

274-
// Check for self-referencing. Skip email processing if a mailbox is configured by the sender's address.
279+
// Check for self-referencing. Skip email processing if a mailbox is configured by the sender's address.
275280
try {
276281
$this->getMailboxByEmail($addresses['from']);
277282
return;
@@ -305,28 +310,7 @@ public function processMail($rawEmail)
305310
$mailData['message'] = autolink($htmlFilter->addClassEmailReplyQuote($parser->getMessageBody('text')));
306311
}
307312

308-
// $mailboxes = $this->getMailboxByEmail($data['replyTo']);
309-
// if(!count($mailboxes)) {
310-
// if($cc) {
311-
// foreach ($cc as $value) {
312-
// $toAdress[] = $value['address'];
313-
// }
314-
// $mailboxes = $this->getMailboxByEmail($toAdress);
315-
316-
// if(count($mailboxes)) {
317-
// foreach ($mailboxes as $mailbox) {
318-
// foreach ($data['cc'] as $key => $value) {
319-
// if (strpos($value, $mailbox->getEmail()) !== FALSE) {
320-
// unset($data['cc'][$key]);
321-
// }
322-
// }
323-
// }
324-
// $data['replyTo'] = $toAdress;
325-
// }
326-
// }
327-
// }
328-
329-
$website = $this->entityManager->getRepository('UVDeskCoreFrameworkBundle:Website')->findOneByCode('knowledgebase');
313+
$website = $this->entityManager->getRepository(Website::class)->findOneByCode('knowledgebase');
330314

331315
if (!empty($mailData['from']) && $this->container->get('ticket.service')->isEmailBlocked($mailData['from'], $website)) {
332316
return;
@@ -345,7 +329,6 @@ public function processMail($rawEmail)
345329
$mailData['threadType'] = 'create';
346330
$mailData['referenceIds'] = $mailData['messageId'];
347331

348-
$this->addCollaboratorFlag = 1;
349332
$thread = $this->container->get('ticket.service')->createTicket($mailData);
350333

351334
// Trigger ticket created event
@@ -356,7 +339,7 @@ public function processMail($rawEmail)
356339
$this->container->get('event_dispatcher')->dispatch('uvdesk.automation.workflow.execute', $event);
357340
} else if (false === $ticket->getIsTrashed() && strtolower($ticket->getStatus()->getCode()) != 'spam') {
358341
$mailData['threadType'] = 'reply';
359-
$thread = $this->entityManager->getRepository('UVDeskCoreFrameworkBundle:Thread')->findOneByMessageId($mailData['messageId']);
342+
$thread = $this->entityManager->getRepository(Thread::class)->findOneByMessageId($mailData['messageId']);
360343

361344
if (!empty($thread)) {
362345
// Thread with the same message id exists. Skip processing.
@@ -370,20 +353,45 @@ public function processMail($rawEmail)
370353
$mailData['user'] = $user;
371354
$userDetails = $user->getCustomerInstance()->getPartialDetails();
372355
} else {
373-
$user = $this->entityManager->getRepository('UVDeskSupportBundle:User')->findOneByEmail($mailData['from']);
374-
356+
$user = $this->entityManager->getRepository(User::class)->findOneByEmail($mailData['from']);
357+
375358
if (!empty($user) && null != $user->getAgentInstance()) {
376359
$mailData['user'] = $user;
377360
$userDetails = $user->getAgentInstance()->getPartialDetails();
378361
} else {
379-
// No user found.
380-
// @TODO: Do something about this case.
381-
return;
362+
// Add user as a ticket collaborator
363+
if (empty($user)) {
364+
// Create a new user instance with customer support role
365+
$role = $this->entityManager->getRepository(SupportRole::class)->findOneByCode('ROLE_CUSTOMER');
366+
367+
$user = $this->container->get('user.service')->createUserInstance($mailData['from'], $mailData['name'], $role, [
368+
'source' => 'email',
369+
'active' => true
370+
]);
371+
}
372+
373+
$mailData['user'] = $user;
374+
$userDetails = $user->getCustomerInstance()->getPartialDetails();
375+
376+
if (false == $this->entityManager->getRepository(Ticket::class)->isTicketCollaborator($ticket, $mailData['from'])) {
377+
$ticket->addCollaborator($user);
378+
379+
$this->entityManager->persist($ticket);
380+
$this->entityManager->flush();
381+
382+
$ticket->lastCollaborator = $user;
383+
384+
$event = new GenericEvent(CoreWorkflowEvents\Ticket\Collaborator::getId(), [
385+
'entity' => $ticket,
386+
]);
387+
388+
$this->container->get('event_dispatcher')->dispatch('uvdesk.automation.workflow.execute', $event);
389+
}
382390
}
383391
}
384392

385393
$mailData['fullname'] = $userDetails['name'];
386-
394+
387395
$thread = $this->container->get('ticket.service')->createThread($ticket, $mailData);
388396

389397
if ($thread->getCreatedBy() == 'customer') {

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.1.3",
13+
"php": "^7.2",
1414
"uvdesk/composer-plugin": "^1.0",
1515
"uvdesk/core-framework": "^1.0",
1616
"iamcal/lib_autolink": "^1.7",

0 commit comments

Comments
 (0)