Jelajahi Sumber

Merge pull request #3692 from pixelfed/staging

Staging
daniel 2 tahun lalu
induk
melakukan
ecbc168361
36 mengubah file dengan 47 tambahan dan 2 penghapusan
  1. 1 0
      CHANGELOG.md
  2. 5 2
      app/Services/MediaStorageService.php
  3. 41 0
      database/migrations/2022_10_09_043758_fix_cdn_url_in_avatars_table.php
  4. TEMPAT SAMPAH
      public/css/admin.css
  5. TEMPAT SAMPAH
      public/css/app.css
  6. TEMPAT SAMPAH
      public/css/appdark.css
  7. TEMPAT SAMPAH
      public/css/landing.css
  8. TEMPAT SAMPAH
      public/js/compose-ivl9d2teh.js
  9. TEMPAT SAMPAH
      public/js/daci-17lx4qxke.js
  10. TEMPAT SAMPAH
      public/js/daci-ivl9d2teh.js
  11. TEMPAT SAMPAH
      public/js/dffc-17lx4qxke.js
  12. TEMPAT SAMPAH
      public/js/dffc-ivl9d2teh.js
  13. TEMPAT SAMPAH
      public/js/discover-ivl9d2teh.js
  14. TEMPAT SAMPAH
      public/js/dms-ivl9d2teh.js
  15. TEMPAT SAMPAH
      public/js/dmsg-ivl9d2teh.js
  16. TEMPAT SAMPAH
      public/js/dmyh-17lx4qxke.js
  17. TEMPAT SAMPAH
      public/js/dmyh-ivl9d2teh.js
  18. TEMPAT SAMPAH
      public/js/dmym-17lx4qxke.js
  19. TEMPAT SAMPAH
      public/js/dmym-ivl9d2teh.js
  20. TEMPAT SAMPAH
      public/js/dsfc-17lx4qxke.js
  21. TEMPAT SAMPAH
      public/js/dsfc-ivl9d2teh.js
  22. TEMPAT SAMPAH
      public/js/dssc-17lx4qxke.js
  23. TEMPAT SAMPAH
      public/js/dssc-ivl9d2teh.js
  24. TEMPAT SAMPAH
      public/js/home-17lx4qxke.js
  25. TEMPAT SAMPAH
      public/js/home-ivl9d2teh.js
  26. TEMPAT SAMPAH
      public/js/live-player.js
  27. TEMPAT SAMPAH
      public/js/manifest.js
  28. TEMPAT SAMPAH
      public/js/notifications-17lx4qxke.js
  29. TEMPAT SAMPAH
      public/js/notifications-ivl9d2teh.js
  30. TEMPAT SAMPAH
      public/js/post-17lx4qxke.js
  31. TEMPAT SAMPAH
      public/js/post-ivl9d2teh.js
  32. TEMPAT SAMPAH
      public/js/profile-17lx4qxke.js
  33. TEMPAT SAMPAH
      public/js/profile-ivl9d2teh.js
  34. TEMPAT SAMPAH
      public/js/spa.js
  35. TEMPAT SAMPAH
      public/js/vendor.js
  36. TEMPAT SAMPAH
      public/mix-manifest.json

+ 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()
+    {
+    }
+}

TEMPAT SAMPAH
public/css/admin.css


TEMPAT SAMPAH
public/css/app.css


TEMPAT SAMPAH
public/css/appdark.css


TEMPAT SAMPAH
public/css/landing.css


TEMPAT SAMPAH
public/js/compose-17lx4qxke.js → public/js/compose-ivl9d2teh.js


TEMPAT SAMPAH
public/js/daci-17lx4qxke.js


TEMPAT SAMPAH
public/js/daci-ivl9d2teh.js


TEMPAT SAMPAH
public/js/dffc-17lx4qxke.js


TEMPAT SAMPAH
public/js/dffc-ivl9d2teh.js


TEMPAT SAMPAH
public/js/discover-17lx4qxke.js → public/js/discover-ivl9d2teh.js


TEMPAT SAMPAH
public/js/dms-17lx4qxke.js → public/js/dms-ivl9d2teh.js


TEMPAT SAMPAH
public/js/dmsg-17lx4qxke.js → public/js/dmsg-ivl9d2teh.js


TEMPAT SAMPAH
public/js/dmyh-17lx4qxke.js


TEMPAT SAMPAH
public/js/dmyh-ivl9d2teh.js


TEMPAT SAMPAH
public/js/dmym-17lx4qxke.js


TEMPAT SAMPAH
public/js/dmym-ivl9d2teh.js


TEMPAT SAMPAH
public/js/dsfc-17lx4qxke.js


TEMPAT SAMPAH
public/js/dsfc-ivl9d2teh.js


TEMPAT SAMPAH
public/js/dssc-17lx4qxke.js


TEMPAT SAMPAH
public/js/dssc-ivl9d2teh.js


TEMPAT SAMPAH
public/js/home-17lx4qxke.js


TEMPAT SAMPAH
public/js/home-ivl9d2teh.js


TEMPAT SAMPAH
public/js/live-player.js


TEMPAT SAMPAH
public/js/manifest.js


TEMPAT SAMPAH
public/js/notifications-17lx4qxke.js


TEMPAT SAMPAH
public/js/notifications-ivl9d2teh.js


TEMPAT SAMPAH
public/js/post-17lx4qxke.js


TEMPAT SAMPAH
public/js/post-ivl9d2teh.js


TEMPAT SAMPAH
public/js/profile-17lx4qxke.js


TEMPAT SAMPAH
public/js/profile-ivl9d2teh.js


TEMPAT SAMPAH
public/js/spa.js


TEMPAT SAMPAH
public/js/vendor.js


TEMPAT SAMPAH
public/mix-manifest.json