Skip to content

Commit c3c9ef8

Browse files
author
steve-ks
committed
Add mail support
* Allow sending emails with generated link * Updated language support * Added webbox config for storage lifetime * Updated responsive design for modal * Moved select storage lifetime to own vue component
1 parent 759887e commit c3c9ef8

File tree

22 files changed

+323
-112
lines changed

22 files changed

+323
-112
lines changed

app/Console/Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class Kernel extends ConsoleKernel
2525
protected function schedule(Schedule $schedule)
2626
{
2727
// Cleanup old upload directories
28-
$schedule->command('upload:cleanup')->hourly();
28+
$schedule->command('upload:cleanup')->everyFifteenMinutes();
2929
// Cleanup old storage directories
30-
$schedule->command('storage:cleanup')->hourly();
30+
$schedule->command('storage:cleanup')->everyFifteenMinutes();
3131
}
3232

3333
/**

app/Http/Controllers/UploadController.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
namespace App\Http\Controllers;
44

5+
use App\Mail\SharedLink;
56
use App\Traits\SessionLifetime;
67
use App\Traits\StorageTime;
78
use App\Traits\StringAdditions;
89
use Illuminate\Http\Request;
910
use Illuminate\Support\Facades\File;
11+
use Illuminate\Support\Facades\Mail;
1012
use Illuminate\Support\Facades\Storage;
1113
use Intervention\Image\Exception\NotReadableException;
1214
use Intervention\Image\Facades\Image;
@@ -118,4 +120,19 @@ public function store(Request $request)
118120
'url' => 'share/'.$sessId
119121
]);
120122
}
123+
124+
/**
125+
* Send an email with the given session id as link
126+
*/
127+
public function sendmail(Request $request)
128+
{
129+
$sessId = $request->session()->get('sessionid');
130+
Mail::to($request->input('email'))
131+
->send(new SharedLink(
132+
$sessId,
133+
$this->getStorageTime($sessId)->isoFormat('LLLL')
134+
));
135+
136+
return response()->json(['success' => true]);
137+
}
121138
}

app/Mail/SharedLink.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace App\Mail;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Mail\Mailable;
7+
use Illuminate\Queue\SerializesModels;
8+
9+
class SharedLink extends Mailable
10+
{
11+
use Queueable, SerializesModels;
12+
13+
/**
14+
* This is the shared link ending date
15+
*/
16+
public $validUntil;
17+
/**
18+
* This is the shared link URL passed to the email
19+
*/
20+
public $url;
21+
22+
/**
23+
* Create a new message instance.
24+
*
25+
* @return void
26+
*/
27+
public function __construct(string $path, string $validUntil)
28+
{
29+
$this->validUntil = $validUntil;
30+
$this->url = preg_replace('/\/*$/', '', config('app.url')) . '/' . $path;
31+
}
32+
33+
/**
34+
* Build the message.
35+
*
36+
* @return $this
37+
*/
38+
public function build()
39+
{
40+
// Use from address as given by config/mail.php
41+
return $this->markdown('emails.shared.link');
42+
}
43+
}

app/User.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"php": "^7.2.5",
1212
"fideloper/proxy": "^4.2",
1313
"fruitcake/laravel-cors": "^1.0",
14-
"guzzlehttp/guzzle": "^6.3",
14+
"guzzlehttp/guzzle": "^6.5",
1515
"illuminate/filesystem": "^7.5",
1616
"intervention/image": "^2.5",
1717
"laravel/framework": "^7.5",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/mail.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
|
1414
*/
1515

16-
'default' => env('MAIL_MAILER', 'smtp'),
16+
'default' => env('MAIL_MAILER', null),
1717

1818
/*
1919
|--------------------------------------------------------------------------
@@ -83,8 +83,8 @@
8383
*/
8484

8585
'from' => [
86-
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
87-
'name' => env('MAIL_FROM_NAME', 'Example'),
86+
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
87+
'name' => env('MAIL_FROM_NAME', 'Shared Webbox Link'),
8888
],
8989

9090
/*

config/webbox.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
// Maximum allowed file size in megabytes (should fit with php & webserver upload limits)
1717
'max_filesize' => env('MAX_FILESIZE_MB', '256'),
1818

19+
// Footer text, can also be empty
20+
'footer_text' => env('FOOTER_TEXT', '&#169; 2020 powered by KingStarter GbR'),
21+
'footer_link' => env('FOOTER_LINK', 'https://kingstarter.de'),
22+
1923
/*
2024
|--------------------------------------------------------------------------
2125
| Honeypot configuration
@@ -30,4 +34,38 @@
3034

3135
// Honeypot field name for form input, should be a known field with some random chars
3236
'honeypot_field' => env('HONEYPOT_FIELD', 'phone_number_4f3dx'),
37+
38+
/*
39+
|--------------------------------------------------------------------------
40+
| Storage lifetime
41+
|--------------------------------------------------------------------------
42+
|
43+
| Set an array of possible storage lifetime durations when generating
44+
| data links. The labels for generic time periods are translated
45+
| automatically with singular and plural modifications added.
46+
|
47+
| NOTE: Cleanup schedules are set to everyFifteenMinutes, to provide
48+
| even shorter lifetimes, the app/Console/Kernel.php cleanup
49+
| schedules need to be called more frequently.
50+
|
51+
*/
52+
53+
// Value format: /[0-9]+ [a-z]+/
54+
'storage_lifetime' => [
55+
'1 hour',
56+
'6 hours',
57+
'1 day',
58+
'2 days',
59+
'3 days',
60+
'1 week',
61+
'2 weeks',
62+
'1 month',
63+
'2 months',
64+
'3 months',
65+
'6 months',
66+
'1 year',
67+
],
68+
69+
// The default lifetime should be one option within the storage duration array
70+
'default_lifetime' => '1 month',
3371
];

public/css/app.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)