diff --git a/be/app/Listeners/SendNewSubTaskEmailNotification.php b/be/app/Listeners/SendNewSubTaskEmailNotification.php
index 826e037..b2c2706 100644
--- a/be/app/Listeners/SendNewSubTaskEmailNotification.php
+++ b/be/app/Listeners/SendNewSubTaskEmailNotification.php
@@ -31,6 +31,17 @@ class SendNewSubTaskEmailNotification implements ShouldQueue
*/
public function handle(SubTaskCreated $event)
{
- Mail::to($event->subtask->user->email)->send(new NewTask($event->subtask));
+ // ked je v subtasku viacej userov, tak poslem 1 email notifikaciu so vsetkymi usermi, ktori su v master tasku
+ if (count($event->subtask->mastertask->subtasks) > 1) {
+ $emails = $event->subtask->mastertask->all_users_in_master_task->pluck('email')->unique()->toArray();
+
+ if (empty($emails)) {
+ return;
+ }
+
+ Mail::to($emails)->send(new NewTask($event->subtask));
+ } else {
+ Mail::to($event->subtask->user->email)->send(new NewTask($event->subtask));
+ }
}
}
diff --git a/be/resources/views/emails/task/sub_task_created.blade.php b/be/resources/views/emails/task/sub_task_created.blade.php
index 6441e1d..2600769 100644
--- a/be/resources/views/emails/task/sub_task_created.blade.php
+++ b/be/resources/views/emails/task/sub_task_created.blade.php
@@ -20,18 +20,20 @@ Odkaz na Task: {{ url( env( 'APP_URL_FE' ) . '/#/app/dashboard/tasks?subtask=' .
$pattern_mac = '/\\\\serverjl\\\\[^ ]*/';
// Define the callback function to replace links
- function replace_smb_links($matches) {
- $link = $matches[0];
- if (strpos($link, 'smb://serverjl') === 0) {
- // Windows link
- $windows_link = str_replace('smb://serverjl', '\\\\serverjl\\', $link);
- return "
Windows: $windows_link
Mac: $link
";
- } elseif (strpos($link, '\\\\serverjl\\') === 0) {
- // Mac link
- $mac_link = str_replace('\\\\serverjl\\', 'smb://serverjl', $link);
- return "
Windows: $link
Mac: $mac_link
";
- }
- return $link; // In case no pattern matches, return the original link
+ if (!function_exists('replace_smb_links')) {
+ function replace_smb_links($matches) {
+ $link = $matches[0];
+ if (strpos($link, 'smb://serverjl') === 0) {
+ // Windows link
+ $windows_link = str_replace('smb://serverjl', '\\\\serverjl\\', $link);
+ return "
Windows: $windows_link
Mac: $link
";
+ } elseif (strpos($link, '\\\\serverjl\\') === 0) {
+ // Mac link
+ $mac_link = str_replace('\\\\serverjl\\', 'smb://serverjl', $link);
+ return "
Windows: $link
Mac: $mac_link
";
+ }
+ return $link; // In case no pattern matches, return the original link
+ }
}
// Replace SMB links using the callback function