Update MediaPathService, fix story path

pull/4270/head
Daniel Supernault 2023-04-02 05:15:38 -06:00
rodzic 4d72b9e3ae
commit aebbad964b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
2 zmienionych plików z 8 dodań i 3 usunięć

Wyświetl plik

@ -9,11 +9,16 @@ class HashidService {
public const MIN_LIMIT = 15;
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;
}
if($minLimit && strlen($id) < self::MIN_LIMIT) {
return null;
}
$key = "hashids:{$id}";
return Cache::remember($key, now()->hours(48), function() use($id) {
$cmap = self::CMAP;

Wyświetl plik

@ -52,7 +52,7 @@ class MediaPathService {
public static function story($account, $version = 1)
{
$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);
if($account instanceOf User) {