mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +00:00
Update MediaPathService, change story paths
This commit is contained in:
parent
168c19c5b6
commit
427f9da33e
1 changed files with 7 additions and 6 deletions
|
@ -8,6 +8,7 @@ use Illuminate\Support\Str;
|
||||||
use App\Media;
|
use App\Media;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use App\Services\HashidService;
|
||||||
|
|
||||||
class MediaPathService {
|
class MediaPathService {
|
||||||
|
|
||||||
|
@ -51,24 +52,24 @@ class MediaPathService {
|
||||||
public static function story($account, $version = 1)
|
public static function story($account, $version = 1)
|
||||||
{
|
{
|
||||||
$mh = hash('sha256', date('Y').'-.-'.date('m'));
|
$mh = hash('sha256', date('Y').'-.-'.date('m'));
|
||||||
$monthHash = date('Y').date('m').substr($mh, 0, 6).substr($mh, 58, 6);
|
$monthHash = HashidService::encode(date('Y').date('m'));
|
||||||
$random = '03'.Str::random(random_int(6,9)).'_'.Str::random(random_int(6,17));
|
$random = date('d').Str::random(32);
|
||||||
|
|
||||||
if($account instanceOf User) {
|
if($account instanceOf User) {
|
||||||
switch ($version) {
|
switch ($version) {
|
||||||
case 1:
|
case 1:
|
||||||
$userHash = $account->profile_id;
|
$userHash = HashidService::encode($account->profile_id);
|
||||||
$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
|
$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$userHash = $account->profile_id;
|
$userHash = HashidService::encode($account->profile_id);
|
||||||
$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
|
$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($account instanceOf Profile) {
|
if($account instanceOf Profile) {
|
||||||
$userHash = $account->id;
|
$userHash = HashidService::encode($account->id);
|
||||||
$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
|
$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
|
||||||
}
|
}
|
||||||
return $path;
|
return $path;
|
||||||
|
|
Loading…
Reference in a new issue