@@ -176,10 +176,6 @@ public function persistActivityActivated(ActivityInterface $activity, TokenInter
176
176
if (!is_null ($ user )) {
177
177
// Review if the task has enable the action by email
178
178
$ this ->validateAndSendActionByEmail ($ activity , $ token , $ user ->email );
179
- // Review if the user has enable the email notification
180
- $ isEmailTaskValid = $ this ->validateEmailUserNotification ($ token , $ user );
181
- // Define the flag if the email needs to sent
182
- $ token ->is_emailsent = $ isEmailTaskValid ? 1 : 0 ;
183
179
}
184
180
$ this ->instanceRepository ->persistInstanceUpdated ($ token ->getInstance ());
185
181
}
@@ -231,71 +227,6 @@ private function validateAndSendActionByEmail(ActivityInterface $activity, Token
231
227
}
232
228
}
233
229
234
- /**
235
- * Validates the user's email notification settings and sends an email if enabled.
236
- *
237
- * @param TokenInterface $token The token containing task information.
238
- * @param User $user The user to whom the email notification will be sent.
239
- * @return mixed|null Returns the result of the email sending operation or null if not sent.
240
- */
241
- private function validateEmailUserNotification (TokenInterface $ token , User $ user )
242
- {
243
- try {
244
- Log::Info ('User isEmailTaskEnable: ' . $ user ->email_task_notification );
245
- // Return if email task notification is not enabled or email is empty
246
- if ($ user ->email_task_notification === 0 || empty ($ user ->email )) {
247
- return null ;
248
- }
249
- // Prepare data for the email
250
- $ data = $ this ->prepareEmailData ($ token , $ user );
251
-
252
- // Send Email
253
- return (new TaskActionByEmail ())->sendAbeEmail ($ data ['configEmail ' ], $ user ->email , $ data ['emailData ' ]);
254
- } catch (\Exception $ e ) {
255
- // Catch and log the error
256
- Log::error ('Failed to validate and send email task notification ' , [
257
- 'error ' => $ e ->getMessage (),
258
- ]);
259
- }
260
- }
261
-
262
- /**
263
- * Prepares the email data and configuration for sending an email notification.
264
- *
265
- * @param TokenInterface $token The token containing task information.
266
- * @param User $user The user for whom the email data is being prepared.
267
- * @return array An associative array containing 'emailData' and 'configEmail'.
268
- */
269
- private function prepareEmailData (TokenInterface $ token , User $ user )
270
- {
271
- // Get the case
272
- $ caseTitle = ProcessRequest::where ('id ' , $ token ->process_request_id )->value ('case_title ' );
273
- // Prepare the email data
274
- $ taskName = $ token ->element_name ?? '' ;
275
- $ emailData = [
276
- 'firstname ' => $ user ->firstname ?? '' ,
277
- 'assigned_by ' => Auth::user ()->fullname ?? __ ('System ' ),
278
- 'element_name ' => $ taskName ,
279
- 'case_title ' => $ caseTitle , // Populate this if needed
280
- 'due_date ' => $ token ->due_at ?? '' ,
281
- 'link_review_task ' => config ('app.url ' ) . '/ ' . 'tasks/ ' . $ token ->id . '/edit ' ,
282
- 'imgHeader ' => config ('app.url ' ) . '/img/processmaker_login.png ' ,
283
- ];
284
- // Get the screen by key
285
- $ screen = Screen::getScreenByKey ('default-email-task-notification ' );
286
- // Prepare the email configuration
287
- $ configEmail = [
288
- 'emailServer ' => 0 , // Use the default email server
289
- 'subject ' => "{$ user ->firstname } assigned you in ' {$ taskName }' " ,
290
- 'screenEmailRef ' => $ screen ->id ?? 0 , // Define here the screen to use
291
- ];
292
-
293
- return [
294
- 'emailData ' => $ emailData ,
295
- 'configEmail ' => $ configEmail ,
296
- ];
297
- }
298
-
299
230
/**
300
231
* Get due Variable
301
232
*
0 commit comments