From aac4430970a3fb13ad77e20b9115eb7332504f04 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 17 Jan 2021 21:46:40 -0700 Subject: [PATCH] Update MediaPathService, add story method --- app/Services/MediaPathService.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/Services/MediaPathService.php b/app/Services/MediaPathService.php index c8ae1422f..a794ce621 100644 --- a/app/Services/MediaPathService.php +++ b/app/Services/MediaPathService.php @@ -48,4 +48,30 @@ class MediaPathService { return $path; } + public static function story($account, $version = 1) + { + $mh = hash('sha256', date('Y').'-.-'.date('m')); + $monthHash = date('Y').date('m').substr($mh, 0, 6).substr($mh, 58, 6); + $random = '03'.Str::random(random_int(6,9)).'_'.Str::random(random_int(6,17)); + + if($account instanceOf User) { + switch ($version) { + case 1: + $userHash = $account->profile_id; + $path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}"; + break; + + default: + $userHash = $account->profile_id; + $path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}"; + break; + } + } + if($account instanceOf Profile) { + $userHash = $account->id; + $path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}"; + } + return $path; + } + } \ No newline at end of file