瀏覽代碼

Update MediaStorageService

Daniel Supernault 2 年之前
父節點
當前提交
d6374cfe70
共有 2 個文件被更改,包括 6 次插入4 次删除
  1. 1 1
      app/Jobs/AvatarPipeline/RemoteAvatarFetchFromUrl.php
  2. 5 3
      app/Services/MediaStorageService.php

+ 1 - 1
app/Jobs/AvatarPipeline/RemoteAvatarFetchFromUrl.php

@@ -84,7 +84,7 @@ class RemoteAvatarFetchFromUrl implements ShouldQueue
 			$avatar->save();
 		}
 
-		MediaStorageService::avatar($avatar, boolval(config_cache('pixelfed.cloud_storage')) == false);
+		MediaStorageService::avatar($avatar, boolval(config_cache('pixelfed.cloud_storage')) == false, true);
 
 		return 1;
 	}

+ 5 - 3
app/Services/MediaStorageService.php

@@ -191,7 +191,7 @@ class MediaStorageService {
 		unlink($tmpName);
 	}
 
-	protected function fetchAvatar($avatar, $local = false)
+	protected function fetchAvatar($avatar, $local = false, $skipRecentCheck = false)
 	{
 		$url = $avatar->remote_url;
 		$driver = $local ? 'local' : config('filesystems.cloud');
@@ -215,8 +215,10 @@ class MediaStorageService {
 		$mime = $head['mime'];
 		$max_size = (int) config('pixelfed.max_avatar_size') * 1000;
 
-		if($avatar->last_fetched_at && $avatar->last_fetched_at->gt(now()->subDay())) {
-			return;
+		if(!$skipRecentCheck) {
+			if($avatar->last_fetched_at && $avatar->last_fetched_at->gt(now()->subDay())) {
+				return;
+			}
 		}
 
 		// handle pleroma edge case