浏览代码

Update MediaPathService, change story paths

Daniel Supernault 3 年之前
父节点
当前提交
427f9da33e
共有 1 个文件被更改,包括 7 次插入6 次删除
  1. 7 6
      app/Services/MediaPathService.php

+ 7 - 6
app/Services/MediaPathService.php

@@ -8,6 +8,7 @@ use Illuminate\Support\Str;
 use App\Media;
 use App\Profile;
 use App\User;
+use App\Services\HashidService;
 
 class MediaPathService {
 
@@ -51,27 +52,27 @@ class MediaPathService {
 	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));
+		$monthHash = HashidService::encode(date('Y').date('m'));
+		$random = date('d').Str::random(32);
 
 		if($account instanceOf User) {
 			switch ($version) {
 				case 1:
-					$userHash = $account->profile_id;
+					$userHash = HashidService::encode($account->profile_id);
 					$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
 					break;
 				
 				default:
-					$userHash = $account->profile_id;
+					$userHash = HashidService::encode($account->profile_id);
 					$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
 					break;
 			}
 		} 
 		if($account instanceOf Profile) {
-			$userHash = $account->id;
+			$userHash = HashidService::encode($account->id);
 			$path = "public/_esm.t3/{$monthHash}/{$userHash}/{$random}";
 		}
 		return $path;
 	}
 
-}
+}