1
0
Fork 0

Update StoryController

This commit is contained in:
Daniel Supernault 2020-01-10 19:45:46 -07:00
parent 5a764473f2
commit d403e0c615
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 83 additions and 82 deletions

View File

@ -26,7 +26,7 @@ class StoryController extends Controller
abort_if(!config('instance.stories.enabled') || !$request->user(), 404);
$this->validate($request, [
'file.*' => function() {
'file' => function() {
return [
'required',
'mimes:image/jpeg,image/png',
@ -41,13 +41,8 @@ class StoryController extends Controller
abort(400, 'You have reached your limit for new Stories today.');
}
$story = new Story();
$story->duration = 3;
$story->profile_id = $user->profile_id;
$story->expires_at = now()->addHours(24);
$story->save();
$monthHash = substr(hash('sha1', date('Y').date('m')), 0, 12);
$sid = Str::uuid();
$rid = Str::random(6).'.'.Str::random(9);
$photo = $request->file('file');
@ -61,11 +56,17 @@ class StoryController extends Controller
return;
}
$storagePath = "public/_esm.t1/{$monthHash}/{$story->id}/{$rid}";
$storagePath = "public/_esm.t1/{$monthHash}/{$sid}/{$rid}";
$path = $photo->store($storagePath);
$story = new Story();
$story->duration = 3;
$story->profile_id = $user->profile_id;
$story->type = 'photo';
$story->mime = $photo->getMimeType();
$story->path = $path;
$story->local = true;
$story->size = $photo->getClientSize();
$story->expires_at = now()->addHours(24);
$story->save();