forked from mirror/pixelfed
Update MediaPathService, add story method
This commit is contained in:
parent
0cfc12c5dd
commit
aac4430970
1 changed files with 26 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue