Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ProcessMaker/Mail/TaskActionByEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function sendAbeEmail($config, $to, $data)
$emailServer = $config['emailServer'] ?? 0;
$subject = $config['subject'] ?? '';
$emailScreenRef = $config['screenEmailRef'] ?? 0;

$emailConfig = [
'subject' => $this->mustache($subject, $data),
'addEmails' => $to,
Expand All @@ -47,7 +47,7 @@ public function sendAbeEmail($config, $to, $data)
'json_data' => '{}',
'emailServer' => $emailServer,
];

if (!empty($emailScreenRef)) {
// Retrieve and render custom screen if specified
$customScreen = Screen::findOrFail($emailScreenRef);
Expand All @@ -56,10 +56,9 @@ public function sendAbeEmail($config, $to, $data)
// Default message if no custom screen is configured
$emailConfig['body'] = __('No screen configured');
}

// Send the email using emailProvider
$this->emailProvider->send($emailConfig);

} catch (\Exception $e) {
Log::error('Error sending ABE email', [
'to' => $to,
Expand All @@ -69,6 +68,8 @@ public function sendAbeEmail($config, $to, $data)
'error' => $e->getMessage(),
]);
}

return true;
}

private function mustache($str, $data)
Expand Down
13 changes: 8 additions & 5 deletions ProcessMaker/Repositories/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ public function persistActivityActivated(ActivityInterface $activity, TokenInter
// Review if the task has enable the action by email
$this->validateAndSendActionByEmail($activity, $token, $user->email);
// Review if the user has enable the email notification
$this->validateEmailUserNotification($token, $user);
$isEmailTaskValid = $this->validateEmailUserNotification($token, $user);
// Define the flag if the email needs to sent
$token->is_emailsent = $isEmailTaskValid ? 1 : 0;
}
$this->instanceRepository->persistInstanceUpdated($token->getInstance());
}
Expand Down Expand Up @@ -241,7 +243,7 @@ private function validateEmailUserNotification(TokenInterface $token, User $user
try {
Log::Info('User isEmailTaskEnable: ' . $user->email_task_notification);
// Return if email task notification is not enabled or email is empty
if (!$user->email_task_notification || empty($user->email)) {
if ($user->email_task_notification === 0 || empty($user->email)) {
return null;
}
// Prepare data for the email
Expand Down Expand Up @@ -276,14 +278,15 @@ private function prepareEmailData(TokenInterface $token, User $user)
'element_name' => $taskName,
'case_title' => $caseTitle, // Populate this if needed
'due_date' => $token->due_at ?? '',
'imgHeader' => config('app.url') . '/img/processmaker-login.svg',
'link_review_task' => config('app.url') . 'tasks/' . $token->id . '/edit',
'imgHeader' => config('app.url') . '/img/processmaker_login.png',
];
// Get the screen
$screen = Screen::where('title', 'Default Email Task Notification')->first();
$screen = Screen::where('title', 'DEFAULT_EMAIL_TASK_NOTIFICATION')->first();
// Prepare the email configuration
$configEmail = [
'emailServer' => 0, // Use the default email server
'subject' => "{$user->firstname} assigned you in {$taskName}",
'subject' => "{$user->firstname} assigned you in '{$taskName}'",
'screenEmailRef' => $screen->id ?? 0, // Define here the screen to use
];

Expand Down
Loading