Skip to content

Commit

Permalink
BAP-12183: Incorrect showing of Emails in Activities tree (#5059)
Browse files Browse the repository at this point in the history
* BAP-12183: Incorrect showing of Emails in Activities tree

* BAP-12183: Incorrect showing of Emails in Activities tree
  • Loading branch information
nenadalm authored and soloma88 committed Dec 8, 2016
1 parent d9667c0 commit 511e124
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/Oro/Bundle/EmailBundle/Controller/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,16 @@ public function viewThreadAction(Email $entity)
*/
public function threadWidgetAction(Email $entity)
{
$emails = $this->get('oro_email.email.thread.provider')->getThreadEmails(
$this->get('doctrine')->getManager(),
$entity
);
$emails = [];
if ($this->getRequest()->get('showSingleEmail', false)) {
$emails[] = $entity;
} else {
$emails = $this->get('oro_email.email.thread.provider')->getThreadEmails(
$this->get('doctrine')->getManager(),
$entity
);
}

$emails = array_filter($emails, function ($email) {
return $this->get('security.context')->isGranted('VIEW', $email);
});
Expand Down
11 changes: 9 additions & 2 deletions src/Oro/Bundle/EmailBundle/Mailer/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,17 @@ public function processSend($message, $emailOrigin)
$this->mailer->prepareSmtpTransport($emailOrigin);
}
}

$messageId = $message->getId();
if (!$this->mailer->send($message)) {
throw new \Swift_SwiftException('An email was not delivered.');
}

/**
* We expect message->getId() to be id of the sent message later,
* but sending of the message generates new id after it's sent
* (https://github.com/swiftmailer/swiftmailer/issues/335)
*/
$message->setId($messageId);
}

/**
Expand Down Expand Up @@ -468,7 +475,7 @@ protected function prepareMessage(EmailModel $model, $parentMessageId, $messageD
*/
protected function prepareEmailUser(EmailModel $model, $origin, $message, $messageDate, $parentMessageId)
{
$messageId = '<' . $message->generateId() . '>';
$messageId = '<' . $message->getId() . '>';
$emailUser = $this->createEmailUser($model, $messageDate, $origin);
if ($origin) {
$emailUser->addFolder($this->getFolder($model->getFrom(), $origin));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% block page_container %}
{{ oro_widget_render({
'widgetType': 'block',
'url': path('oro_email_thread_widget', {'id': entity.id}),
'url': path('oro_email_thread_widget', {'id': entity.id, 'showSingleEmail': not oro_config_value('oro_activity_list.grouping')}),
'alias': 'thread-view'
}) }}
{% endblock %}

0 comments on commit 511e124

Please sign in to comment.