From c4d4a2c7e5c420c37bee4cdddc9df0dcb91d9f7b Mon Sep 17 00:00:00 2001 From: Michal Feher Date: Tue, 30 Jul 2024 14:42:02 +0200 Subject: [PATCH 1/3] links in email notifications --- .../emails/task/sub_task_created.blade.php | 28 +++++++++++++++++-- be/routes/web.php | 13 +++++++-- 2 files changed, 35 insertions(+), 6 deletions(-) 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 ed59812..f86a410 100644 --- a/be/resources/views/emails/task/sub_task_created.blade.php +++ b/be/resources/views/emails/task/sub_task_created.blade.php @@ -13,9 +13,31 @@ Odkaz na Task: {{ url( env( 'APP_URL_FE' ) . '/#/app/dashboard/tasks?subtask=' . @php + $description = ($subtask->description) ?: $subtask->mastertask->description; + + // Define regular expressions for Windows and Mac SMB links + $pattern_windows = '/smb:\/\/serverjl[^ ]*/'; + $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 + $mac_link = str_replace('smb://serverjl', '\\\\serverjl\\', $link); + return "
Windows: $link
Mac: $mac_link
"; + } elseif (strpos($link, '\\\\serverjl\\') === 0) { + // Mac link + $windows_link = str_replace('\\\\serverjl\\', 'smb://serverjl', $link); + return "
Windows: $windows_link
Mac: $link
"; + } + return $link; // In case no pattern matches, return the original link + } + + // Replace SMB links using the callback function + $description = preg_replace_callback($pattern_windows, 'replace_smb_links', $description); + $description = preg_replace_callback($pattern_mac, 'replace_smb_links', $description); - $test = 'testtesttest'; @endphp -Popis: {!!($subtask->description) ?: $subtask->mastertask->description !!}
-Popis2: {{$test}}
+Popis: {!!$description!!}
diff --git a/be/routes/web.php b/be/routes/web.php index 3c1aed4..33e21fe 100644 --- a/be/routes/web.php +++ b/be/routes/web.php @@ -1,7 +1,6 @@ find(1622); + + Mail::to('feher@studiotem.com')->send(new NewTask($subtask)); + + return 'Email has been sent'; +}); + + Route::prefix('be')->group(function () { Route::get('/unauthenticated', function () { return response()->json([ @@ -30,7 +38,6 @@ Route::prefix('be')->group(function () { $subtask = \App\Models\SubTask::with('mastertask')->find(1); dd($subtask); - }); }); From 3e5f5e4f55273da8734e475a4c97e9a7eb5a167f Mon Sep 17 00:00:00 2001 From: Michal Feher Date: Tue, 30 Jul 2024 14:49:39 +0200 Subject: [PATCH 2/3] no message --- be/resources/views/emails/task/sub_task_created.blade.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 f86a410..90dda97 100644 --- a/be/resources/views/emails/task/sub_task_created.blade.php +++ b/be/resources/views/emails/task/sub_task_created.blade.php @@ -24,12 +24,12 @@ Odkaz na Task: {{ url( env( 'APP_URL_FE' ) . '/#/app/dashboard/tasks?subtask=' . $link = $matches[0]; if (strpos($link, 'smb://serverjl') === 0) { // Windows link - $mac_link = str_replace('smb://serverjl', '\\\\serverjl\\', $link); - return "
Windows: $link
Mac: $mac_link
"; + $windows_link = str_replace('smb://serverjl', '\\\\serverjl\\', $link); + return "
Windows: $link
Mac: $windows_link
"; } elseif (strpos($link, '\\\\serverjl\\') === 0) { // Mac link - $windows_link = str_replace('\\\\serverjl\\', 'smb://serverjl', $link); - return "
Windows: $windows_link
Mac: $link
"; + $mac_link = str_replace('\\\\serverjl\\', 'smb://serverjl', $link); + return "
Windows: $mac_link
Mac: $link
"; } return $link; // In case no pattern matches, return the original link } From 0b6affda611aaeb740c0b328860aa5684aa1fe29 Mon Sep 17 00:00:00 2001 From: Michal Feher Date: Tue, 30 Jul 2024 14:55:09 +0200 Subject: [PATCH 3/3] no message --- be/resources/views/emails/task/sub_task_created.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 90dda97..6441e1d 100644 --- a/be/resources/views/emails/task/sub_task_created.blade.php +++ b/be/resources/views/emails/task/sub_task_created.blade.php @@ -25,11 +25,11 @@ Odkaz na Task: {{ url( env( 'APP_URL_FE' ) . '/#/app/dashboard/tasks?subtask=' . if (strpos($link, 'smb://serverjl') === 0) { // Windows link $windows_link = str_replace('smb://serverjl', '\\\\serverjl\\', $link); - return "
Windows: $link
Mac: $windows_link
"; + return "
Windows: $windows_link
Mac: $link
"; } elseif (strpos($link, '\\\\serverjl\\') === 0) { // Mac link $mac_link = str_replace('\\\\serverjl\\', 'smb://serverjl', $link); - return "
Windows: $mac_link
Mac: $link
"; + return "
Windows: $link
Mac: $mac_link
"; } return $link; // In case no pattern matches, return the original link }