Преглед изворни кода

Merge pull request #3692 from pixelfed/staging

Staging
daniel пре 2 година
родитељ
комит
ecbc168361

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@
 - Update ApiV1Controller, include self likes in favourited_by endpoint ([58b331d2](https://github.com/pixelfed/pixelfed/commit/58b331d2))
 - Update PublicApiController, remove expensive and unused relationships ([2ecc3144](https://github.com/pixelfed/pixelfed/commit/2ecc3144))
 - Update status deletion, fix database lock issues and side effects ([04e8c96a](https://github.com/pixelfed/pixelfed/commit/04e8c96a))
+- Fix remote profile avatar urls when storing locally ([b0422d4f](https://github.com/pixelfed/pixelfed/commit/b0422d4f))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)

+ 5 - 2
app/Services/MediaStorageService.php

@@ -236,7 +236,10 @@ class MediaStorageService {
 		$tmpBase = storage_path('app/remcache/');
 		$tmpPath = 'avatar_' . $avatar->profile_id . '-' . $path;
 		$tmpName = $tmpBase . $tmpPath;
-		$data = file_get_contents($url, false, null, 0, $head['length']);
+		$data = @file_get_contents($url, false, null, 0, $head['length']);
+		if(!$data) {
+			return;
+		}
 		file_put_contents($tmpName, $data);
 
 		$disk = Storage::disk($driver);
@@ -245,7 +248,7 @@ class MediaStorageService {
 
 		$avatar->media_path = $base . $path;
 		$avatar->is_remote = true;
-		$avatar->cdn_url = $permalink;
+		$avatar->cdn_url = $local ? config('app.url') . $permalink : $permalink;
 		$avatar->size = $head['length'];
 		$avatar->change_count = $avatar->change_count + 1;
 		$avatar->last_fetched_at = now();

+ 41 - 0
database/migrations/2022_10_09_043758_fix_cdn_url_in_avatars_table.php

@@ -0,0 +1,41 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Facades\Cache;
+use App\Services\AccountService;
+use App\Avatar;
+
+class FixCdnUrlInAvatarsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        $baseUrl = 'https://' . config('pixelfed.domain.app');
+        Avatar::whereNotNull('cdn_url')
+        ->chunk(50, function($avatars) use($baseUrl) {
+            foreach($avatars as $avatar) {
+                if(substr($avatar->cdn_url, 0, 23) === '/storage/cache/avatars/') {
+                    $avatar->cdn_url = $baseUrl . $avatar->cdn_url;
+                    $avatar->save();
+                }
+                Cache::forget('avatar:' . $avatar->profile_id);
+                AccountService::del($avatar->profile_id);
+            }
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+    }
+}

BIN
public/css/admin.css


BIN
public/css/app.css


BIN
public/css/appdark.css


BIN
public/css/landing.css


BIN
public/js/compose-17lx4qxke.js → public/js/compose-ivl9d2teh.js


BIN
public/js/daci-17lx4qxke.js


BIN
public/js/daci-ivl9d2teh.js


BIN
public/js/dffc-17lx4qxke.js


BIN
public/js/dffc-ivl9d2teh.js


BIN
public/js/discover-17lx4qxke.js → public/js/discover-ivl9d2teh.js


BIN
public/js/dms-17lx4qxke.js → public/js/dms-ivl9d2teh.js


BIN
public/js/dmsg-17lx4qxke.js → public/js/dmsg-ivl9d2teh.js


BIN
public/js/dmyh-17lx4qxke.js


BIN
public/js/dmyh-ivl9d2teh.js


BIN
public/js/dmym-17lx4qxke.js


BIN
public/js/dmym-ivl9d2teh.js


BIN
public/js/dsfc-17lx4qxke.js


BIN
public/js/dsfc-ivl9d2teh.js


BIN
public/js/dssc-17lx4qxke.js


BIN
public/js/dssc-ivl9d2teh.js


BIN
public/js/home-17lx4qxke.js


BIN
public/js/home-ivl9d2teh.js


BIN
public/js/live-player.js


BIN
public/js/manifest.js


BIN
public/js/notifications-17lx4qxke.js


BIN
public/js/notifications-ivl9d2teh.js


BIN
public/js/post-17lx4qxke.js


BIN
public/js/post-ivl9d2teh.js


BIN
public/js/profile-17lx4qxke.js


BIN
public/js/profile-ivl9d2teh.js



BIN
public/js/vendor.js


BIN
public/mix-manifest.json