mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-30 16:30:45 +00:00
Update StatusController
This commit is contained in:
parent
1c142d4a9b
commit
fddc698a74
1 changed files with 13 additions and 10 deletions
|
@ -2,23 +2,21 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Auth, Cache;
|
||||
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
||||
use Illuminate\Http\Request;
|
||||
use App\{Media, Profile, Status, User};
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
|
||||
class StatusController extends Controller
|
||||
{
|
||||
public function show(Request $request, $username, $hashid)
|
||||
public function show(Request $request, $username, int $id)
|
||||
{
|
||||
$user = Profile::whereUsername($username)->firstOrFail();
|
||||
$id = Hashids::decode($hashid);
|
||||
if(empty($id)) {
|
||||
abort(404);
|
||||
} else {
|
||||
$id = $id[0];
|
||||
}
|
||||
$status = Status::whereProfileId($user->id)->findOrFail($id);
|
||||
if(!$status->media_path && $status->in_reply_to_id) {
|
||||
return view('status.reply', compact('user', 'status'));
|
||||
}
|
||||
return view('status.show', compact('user', 'status'));
|
||||
}
|
||||
|
||||
|
@ -32,9 +30,10 @@ class StatusController extends Controller
|
|||
$user = Auth::user();
|
||||
|
||||
$this->validate($request, [
|
||||
'photo' => 'required|image|max:8000',
|
||||
'photo' => 'required|image|max:15000',
|
||||
'caption' => 'string|max:150'
|
||||
]);
|
||||
|
||||
$monthHash = hash('sha1', date('Y') . date('m'));
|
||||
$userHash = hash('sha1', $user->id . (string) $user->created_at);
|
||||
$storagePath = "public/m/{$monthHash}/{$userHash}";
|
||||
|
@ -54,6 +53,10 @@ class StatusController extends Controller
|
|||
$media->size = $request->file('photo')->getClientSize();
|
||||
$media->mime = $request->file('photo')->getClientMimeType();
|
||||
$media->save();
|
||||
NewStatusPipeline::dispatch($status, $media);
|
||||
|
||||
// TODO: Parse Caption
|
||||
// TODO: Send to subscribers
|
||||
|
||||
return redirect($status->url());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue