Переглянути джерело

Merge pull request #3879 from pixelfed/staging

Staging
daniel 2 роки тому
батько
коміт
09ad8849b5

+ 1 - 0
CHANGELOG.md

@@ -35,6 +35,7 @@
 - Refactor AvatarStorage to support migrating avatars to cloud storage, fix remote avatar refetching and merge AvatarSync commands and add deprecation notice to avatar:sync command ([223aea47](https://github.com/pixelfed/pixelfed/commit/223aea47))
 - Update AvatarStorage, improve overview calculations ([733b9fd0](https://github.com/pixelfed/pixelfed/commit/733b9fd0))
 - Update filesystem config, fix DO Spaces root default ([720b6eb3](https://github.com/pixelfed/pixelfed/commit/720b6eb3))
+- Update Avatar pipeline, fix cloud storage media_path ([02edd19d](https://github.com/pixelfed/pixelfed/commit/02edd19d))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)

+ 2 - 2
app/Console/Commands/AvatarStorage.php

@@ -196,8 +196,8 @@ class AvatarStorage extends Command
                         continue;
                     }
                     $newMediaPath = $disk->put($newPath, $existing);
-                    $avatar->media_path = $newMediaPath;
-                    $avatar->cdn_url = $disk->url($newMediaPath);
+                    $avatar->media_path = $newPath;
+                    $avatar->cdn_url = $disk->url($newPath);
                     $avatar->save();
                 }
 

+ 2 - 1
app/Jobs/AvatarPipeline/AvatarOptimize.php

@@ -93,8 +93,9 @@ class AvatarOptimize implements ShouldQueue
 		$base = 'cache/avatars/' . $avatar->profile_id;
 		$disk = Storage::disk(config('filesystems.cloud'));
 		$disk->deleteDirectory($base);
-		$path = $base . '/' . 'a' . strtolower(Str::random(random_int(3,6))) . $avatar->change_count . '.' . pathinfo($avatar->media_path, PATHINFO_EXTENSION);
+		$path = $base . '/' . 'avatar_' . strtolower(Str::random(random_int(3,6))) . $avatar->change_count . '.' . pathinfo($avatar->media_path, PATHINFO_EXTENSION);
 		$url = $disk->put($path, Storage::get($avatar->media_path));
+		$avatar->media_path = $path;
 		$avatar->cdn_url = $disk->url($path);
 		$avatar->save();
 		Storage::delete($avatar->media_path);

+ 1 - 1
app/Services/MediaStorageService.php

@@ -229,7 +229,7 @@ class MediaStorageService {
 
 		$base = ($local ? 'public/cache/' : 'cache/') . 'avatars/' . $avatar->profile_id;
 		$ext = $head['mime'] == 'image/jpeg' ? 'jpg' : 'png';
-		$path = Str::random(20) . '_avatar.' . $ext;
+		$path = 'avatar_' . strtolower(Str::random(random_int(3,6))) . '.' . $ext;
 		$tmpBase = storage_path('app/remcache/');
 		$tmpPath = 'avatar_' . $avatar->profile_id . '-' . $path;
 		$tmpName = $tmpBase . $tmpPath;

+ 3 - 2
app/Util/ActivityPub/Helpers.php

@@ -496,7 +496,8 @@ class Helpers {
 				$status->in_reply_to_id === null &&
 				$status->reblog_of_id === null &&
 				in_array($status->type, ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) &&
-				$status->created_at->gt(now()->subHours(config('instance.timeline.network.max_hours_old')))
+				$status->created_at->gt(now()->subHours(config('instance.timeline.network.max_hours_old'))) &&
+				(config('instance.hide_nsfw_on_public_feeds') == true ? $status->is_nsfw == false : true)
 			) {
 				NetworkTimelineService::add($status->id);
 			}
@@ -544,7 +545,7 @@ class Helpers {
 	public static function getScope($activity, $url)
 	{
 		$id = isset($activity['id']) ? self::pluckval($activity['id']) : self::pluckval($url);
-		$url = isset($activity['url']) ? self::pluckval($activity['url']) : $id;
+		$url = isset($activity['url']) ? self::pluckval($activity['url']) : self::pluckval($id);
 		$urlDomain = parse_url($url, PHP_URL_HOST);
 		$scope = 'private';