mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-10 22:20:46 +00:00
commit
2461fe905c
1 changed files with 83 additions and 82 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue