فهرست منبع

Update MediaPathService, fix story path

Daniel Supernault 2 سال پیش
والد
کامیت
aebbad964b
2فایلهای تغییر یافته به همراه8 افزوده شده و 3 حذف شده
  1. 7 2
      app/Services/HashidService.php
  2. 1 1
      app/Services/MediaPathService.php

+ 7 - 2
app/Services/HashidService.php

@@ -9,11 +9,16 @@ class HashidService {
 	public const MIN_LIMIT = 15;
 	public const MIN_LIMIT = 15;
 	public const CMAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
 	public const CMAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
 
 
-	public static function encode($id)
+	public static function encode($id, $minLimit = true)
 	{
 	{
-		if(!is_numeric($id) || $id > PHP_INT_MAX || strlen($id) < self::MIN_LIMIT) {
+		if(!is_numeric($id) || $id > PHP_INT_MAX) {
 			return null;
 			return null;
 		}
 		}
+
+		if($minLimit && strlen($id) < self::MIN_LIMIT) {
+			return null;
+		}
+
 		$key = "hashids:{$id}";
 		$key = "hashids:{$id}";
 		return Cache::remember($key, now()->hours(48), function() use($id) {
 		return Cache::remember($key, now()->hours(48), function() use($id) {
 			$cmap = self::CMAP;
 			$cmap = self::CMAP;

+ 1 - 1
app/Services/MediaPathService.php

@@ -52,7 +52,7 @@ 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 = HashidService::encode(date('Y').date('m'));
+		$monthHash = HashidService::encode(date('Y').date('m'), false);
 		$random = date('d').Str::random(32);
 		$random = date('d').Str::random(32);
 
 
 		if($account instanceOf User) {
 		if($account instanceOf User) {