Skip to content

Commit

Permalink
FIX: Email Content
Browse files Browse the repository at this point in the history
Fixes: commit 815d234

based on suggestions by @creecros
  • Loading branch information
aljawaid committed Oct 20, 2022
1 parent 815d234 commit 7fd5b6b
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions Action/EmailTaskHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,30 @@ public function doAction(array $data)
$user = $this->userModel->getById($data['task']['owner_id']);

if (! empty($user['email'])) {
$myHTML = $this->template->render('notification/task_create', array('task' => $data['task']));
$myHTML = $myHTML . $this->template->render('task_comments/show', array(
'task' => $data['task'],
'comments' => $comments,
'project' => $this->projectModel->getById($data['task']['project_id']),
'editable' => false,
));
$myHTML = $myHTML . $this->template->render('notification/footer', array('task' => $data['task']));

// Send email
$this->emailClient->send(
$user['email'],
$user['name'] ?: $user['username'],
$subject,
$this->template->render('notification/task_create', array('task' => $task))
$this->template->render('task_comments/show', array(
'task' => $data['task'],
'comments' => $comments,
'project' => $this->projectModel->getById($data['task']['project_id']),
'editable' => false,
)),
$this->template->render('notification/footer', array('task' => $task))
$myHTML
);

// Add comment to task to show an email has been fired
$this->commentModel->create( array(
'comment' => t('Task history emailed to the task assignee '.$user['username'].' with subject <code>'. $subject).'</code>',
'user_id' => $user['id'],
'task_id' => $data['task']['id'],
));

$historySent = TRUE;
//an easy way to test code is to use error_log, assuming you know how to check your error logs
error_log("I worked",0);
Expand All @@ -93,26 +97,30 @@ public function doAction(array $data)
$user = $this->userModel->getById($data['task']['creator_id']);

if (! empty($user['email'])) {
$myHTML = $this->template->render('notification/task_create', array('task' => $data['task']));
$myHTML = $myHTML . $this->template->render('task_comments/show', array(
'task' => $data['task'],
'comments' => $comments,
'project' => $this->projectModel->getById($data['task']['project_id']),
'editable' => false,
));
$myHTML = $myHTML . $this->template->render('notification/footer', array('task' => $data['task']));

// Send email
$this->emailClient->send(
$user['email'],
$user['name'] ?: $user['username'],
$subject,
$this->template->render('notification/task_create', array('task' => $task))
$this->template->render('task_comments/show', array(
'task' => $data['task'],
'comments' => $comments,
'project' => $this->projectModel->getById($data['task']['project_id']),
'editable' => false,
)),
$this->template->render('notification/footer', array('task' => $task))
$myHTML
);

// Add comment to task to show an email has been fired
$this->commentModel->create( array(
'comment' => t('Task history emailed to the task creator '.$user['username'].' with subject <code>'. $subject).'</code>',
'user_id' => $user['id'],
'task_id' => $data['task']['id'],
));

$historySent = TRUE;
error_log("I worked",0);
}
Expand Down

2 comments on commit 7fd5b6b

@aljawaid
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@creecros thanks for your suggestions, does this make it work? (I did what you said, I hope I understood it correctly)

@aljawaid
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this, it seems to work!

Please sign in to comment.