瀏覽代碼

Merge pull request #3791 from pixelfed/staging

Staging
daniel 2 年之前
父節點
當前提交
5613f6e84f

+ 5 - 0
CHANGELOG.md

@@ -19,6 +19,11 @@
 - Update ApiV1Controller, fix followAccountById with firstOrCreate() ([1d52ad0b](https://github.com/pixelfed/pixelfed/commit/1d52ad0b))
 - Update AccountService, fix delete status ([8b7121f9](https://github.com/pixelfed/pixelfed/commit/8b7121f9))
 - Update ap helpers, fix duplicate entry bug ([85cfa1ba](https://github.com/pixelfed/pixelfed/commit/85cfa1ba))
+- Update Inbox, fix handleUndoActivity ([d660e46b](https://github.com/pixelfed/pixelfed/commit/d660e46b))
+- Update HomeSettings controller, bail earlier when attempting to update email that already exists ([399bf5f8](https://github.com/pixelfed/pixelfed/commit/399bf5f8))
+- Update ProfileController, cache actor object and atom feed ([8665eab1](https://github.com/pixelfed/pixelfed/commit/8665eab1))
+- Update NotificationTransformer, fix mediaTag and modLog types ([b6c06c4b](https://github.com/pixelfed/pixelfed/commit/b6c06c4b))
+- Update landing view, add `app.name` and `app.short_description` for better customizability ([bda9d16b](https://github.com/pixelfed/pixelfed/commit/bda9d16b))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)

+ 43 - 30
app/Http/Controllers/ProfileController.php

@@ -187,10 +187,12 @@ class ProfileController extends Controller
 		abort_if(!config_cache('federation.activitypub.enabled'), 404);
 		abort_if($user->domain, 404);
 
-		$fractal = new Fractal\Manager();
-		$resource = new Fractal\Resource\Item($user, new ProfileTransformer);
-		$res = $fractal->createData($resource)->toArray();
-		return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json');
+		return Cache::remember('pf:activitypub:user-object:by-id:' . $user->id, 3600, function() use($user) {
+			$fractal = new Fractal\Manager();
+			$resource = new Fractal\Resource\Item($user, new ProfileTransformer);
+			$res = $fractal->createData($resource)->toArray();
+			return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json');
+		});
 	}
 
 	public function showAtomFeed(Request $request, $user)
@@ -201,36 +203,47 @@ class ProfileController extends Controller
 
 		abort_if(!$pid, 404);
 
-		$profile = AccountService::get($pid);
+		$profile = AccountService::get($pid, true);
 
 		abort_if(!$profile || $profile['locked'] || !$profile['local'], 404);
 
-		$items = DB::table('statuses')
-			->whereProfileId($pid)
-			->whereVisibility('public')
-			->whereType('photo')
-			->orderByDesc('id')
-			->take(10)
-			->get()
-			->map(function($status) {
-				return StatusService::get($status->id);
-			})
-			->filter(function($status) {
-				return $status &&
-					isset($status['account']) &&
-					isset($status['media_attachments']) &&
-					count($status['media_attachments']);
-			})
-			->values();
-		$permalink = config('app.url') . "/users/{$profile['username']}.atom";
-		$headers = ['Content-Type' => 'application/atom+xml'];
-
-		if($items && $items->count()) {
-			$headers['Last-Modified'] = now()->parse($items->first()['created_at'])->toRfc7231String();
-		}
+		$data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 86400, function() use($pid, $profile) {
+			$items = DB::table('statuses')
+				->whereProfileId($pid)
+				->whereVisibility('public')
+				->whereType('photo')
+				->orderByDesc('id')
+				->take(10)
+				->get()
+				->map(function($status) {
+					return StatusService::get($status->id);
+				})
+				->filter(function($status) {
+					return $status &&
+						isset($status['account']) &&
+						isset($status['media_attachments']) &&
+						count($status['media_attachments']);
+				})
+				->values();
+			$permalink = config('app.url') . "/users/{$profile['username']}.atom";
+			$headers = ['Content-Type' => 'application/atom+xml'];
+
+			if($items && $items->count()) {
+				$headers['Last-Modified'] = now()->parse($items->first()['created_at'])->toRfc7231String();
+			}
+
+			return compact('items', 'permalink', 'headers');
+		});
+		abort_if(!$data, 404);
 		return response()
-			->view('atom.user', compact('profile', 'items', 'permalink'))
-			->withHeaders($headers);
+			->view('atom.user',
+				[
+					'profile' => $profile,
+					'items' => $data['items'],
+					'permalink' => $data['permalink']
+				]
+			)
+			->withHeaders($data['headers']);
 	}
 
 	public function meRedirect()

+ 1 - 1
app/Http/Controllers/Settings/HomeSettings.php

@@ -159,7 +159,7 @@ trait HomeSettings
 	public function emailUpdate(Request $request)
 	{
 		$this->validate($request, [
-			'email'   => 'required|email',
+			'email'   => 'required|email|unique:users,email',
 		]);
 		$changes = false;
 		$email = $request->input('email');

+ 12 - 8
app/Transformer/Api/NotificationTransformer.php

@@ -32,18 +32,22 @@ class NotificationTransformer extends Fractal\TransformerAbstract
 
 		if($n->item_id && $n->item_type == 'App\ModLog') {
 			$ml = $n->item;
-			$res['modlog'] = [
-				'id' => $ml->object_uid,
-				'url' => url('/i/admin/users/modlogs/' . $ml->object_uid)
-			];
+			if($ml && $ml->object_uid) {
+				$res['modlog'] = [
+					'id' => $ml->object_uid,
+					'url' => url('/i/admin/users/modlogs/' . $ml->object_uid)
+				];
+			}
 		}
 
 		if($n->item_id && $n->item_type == 'App\MediaTag') {
 			$ml = $n->item;
-			$res['tagged'] = [
-				'username' => $ml->tagged_username,
-				'post_url' => '/p/'.HashidService::encode($ml->status_id)
-			];
+			if($ml && $ml->tagged_username) {
+				$res['tagged'] = [
+					'username' => $ml->tagged_username,
+					'post_url' => '/p/'.HashidService::encode($ml->status_id)
+				];
+			}
 		}
 
 		return $res;

+ 3 - 3
config/laravel-ffmpeg.php

@@ -13,9 +13,9 @@ return [
 
     'timeout' => 3600,
 
-    'enable_logging' => env('FFMPEG_LOG', false),
-
-    'set_command_and_error_output_on_exception' => false,
+    'log_channel' => env('FFMPEG_LOG_CHANNEL', false),   // set to false to completely disable logging
 
     'temporary_files_root' => env('FFMPEG_TEMPORARY_FILES_ROOT', sys_get_temp_dir()),
+
+    'temporary_files_encrypted_hls' => env('FFMPEG_TEMPORARY_ENCRYPTED_HLS', env('FFMPEG_TEMPORARY_FILES_ROOT', sys_get_temp_dir())),
 ];

+ 5 - 2
resources/views/site/index.blade.php

@@ -53,15 +53,18 @@
 						<p class="display-2 font-weight-bold">Photo Sharing</p>
 						<p class="h1 font-weight-bold">For Everyone.</p>
 					</div>
+
+                    <p class="lead font-weight-light mt-5">{{ config_cache('app.short_description') ?? 'Pixelfed is an image sharing platform, an ethical alternative to centralized platforms.' }}</p>
+                    <p><a href="https://pixelfed.org" target="_blank" class="font-weight-bold">Learn more</a></p>
 				</div>
 				<div class="col-12 col-md-5 offset-md-1">
 					<div>
 						<div class="pt-md-3 d-flex justify-content-center align-items-center">
 							<img src="/img/pixelfed-icon-color.svg" loading="lazy" width="50px" height="50px">
-							<span class="font-weight-bold h3 ml-2 pt-2">Pixelfed</span>
+							<span class="font-weight-bold h3 ml-2 pt-2">{{ config_cache('app.name') ?? 'Pixelfed' }}</span>
 						</div>
 						<div class="d-block d-md-none">
-							<p class="font-weight-bold mb-0 text-center">Photo Sharing. For Everyone</p>
+							<p class="font-weight-light mt-3 mb-5 text-center px-5">{{ config_cache('app.short_description') ?? 'Pixelfed is an image sharing platform, an ethical alternative to centralized platforms.' }}</p>
 						</div>
 						<div class="card my-4 shadow-none border">
 							<div class="card-body px-lg-5">