From 8c54ab57acf0cee98c8f315531e9e02cb97df431 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 25 Jan 2022 00:05:00 -0700 Subject: [PATCH 1/4] Update web routes, fix atom feeds for account usernames containing a dot --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 44b997a49..f60643d52 100644 --- a/routes/web.php +++ b/routes/web.php @@ -516,7 +516,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::group(['prefix' => 'users'], function () { Route::redirect('/', '/'); - Route::get('{user}.atom', 'ProfileController@showAtomFeed'); + Route::get('{user}.atom', 'ProfileController@showAtomFeed')->where('user', '.*'); Route::get('{username}/outbox', 'FederationController@userOutbox'); Route::get('{username}/followers', 'FederationController@userFollowers'); Route::get('{username}/following', 'FederationController@userFollowing'); From 5d9b6863b66f092100380f88d00df65086e4a1d1 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 25 Jan 2022 00:39:46 -0700 Subject: [PATCH 2/4] Update atom feeds, include media alt text. Fixes #3184 --- app/Http/Controllers/ProfileController.php | 46 +++++++++++------ resources/views/atom/user.blade.php | 58 +++++++++++----------- 2 files changed, 61 insertions(+), 43 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index eb841178a..83872b443 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use Auth; use Cache; +use DB; use View; use App\Follower; use App\FollowRequest; @@ -15,6 +16,7 @@ use App\UserFilter; use League\Fractal; use App\Services\AccountService; use App\Services\FollowerService; +use App\Services\StatusService; use App\Util\Lexer\Nickname; use App\Util\Webfinger\Webfinger; use App\Transformer\ActivityPub\ProfileOutbox; @@ -187,20 +189,36 @@ class ProfileController extends Controller { abort_if(!config('federation.atom.enabled'), 404); - $profile = $user = Profile::whereNull('status')->whereNull('domain')->whereUsername($user)->whereIsPrivate(false)->firstOrFail(); - if($profile->status != null) { - return $this->accountCheck($profile); - } - if($profile->is_private || Auth::check()) { - $blocked = $this->blockedProfileCheck($profile); - $check = $this->privateProfileCheck($profile, null); - if($check || $blocked) { - return redirect($profile->url()); - } - } - $items = $profile->statuses()->whereHas('media')->whereIn('visibility',['public', 'unlisted'])->orderBy('created_at', 'desc')->take(10)->get(); - return response()->view('atom.user', compact('profile', 'items')) - ->header('Content-Type', 'application/atom+xml'); + $pid = AccountService::usernameToId($user); + + abort_if(!$pid, 404); + + $profile = AccountService::get($pid); + + abort_if(!$profile || $profile['locked'] || !$profile['local'], 404); + + $items = DB::table('statuses') + ->whereProfileId($pid) + ->whereVisibility('public') + ->whereType('photo') + ->latest() + ->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"; + + return response() + ->view('atom.user', compact('profile', 'items', 'permalink')) + ->header('Content-Type', 'application/atom+xml'); } public function meRedirect() diff --git a/resources/views/atom/user.blade.php b/resources/views/atom/user.blade.php index a99263038..219c11ce4 100644 --- a/resources/views/atom/user.blade.php +++ b/resources/views/atom/user.blade.php @@ -1,38 +1,38 @@ ` won't get parsed as short tags */ - ''.PHP_EOL + /* Using an echo tag here so the `` won't get parsed as short tags */ + ''.PHP_EOL ?> - {{$profile->permalink('.atom')}} - {{$profile->username}} on Pixelfed - {{$profile->bio}} - {{$profile->updated_at->toAtomString()}} + {{$permalink}} + {{$profile['username']}} on Pixelfed + {{$profile['note']}} + {{$profile['created_at']}} - {{$profile->permalink()}} - {{$profile->permalink()}} - {{$profile->permalink()}} - {{$profile->bio}} - - + {{$profile['url']}} + {{$profile['url']}} + {{$profile['url']}} + {{$profile['note']}} + + - - + + @foreach($items as $item) - - {{ $item->caption }} - - {{ $item->url() }} - - profile->username }}]]> - - - iteration}}" src="{{ $item->thumb() }}"> -

{{ $item->caption }}

- ]]> -
- {{ $item->updated_at->toAtomString() }} -
+ + {{ strip_tags($item['content']) }} + + {{ $item['url'] }} + + + + + iteration}}" src="{{ $item['media_attachments'][0]['url'] }}" alt="{{ $item['media_attachments'][0]['description'] }}"> +

{{ $item['content'] }}

+ ]]> +
+ {{ $item['created_at'] }} +
@endforeach
From c6d2db68a0702aae469ed8d6658f4f7e6f2238fe Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 25 Jan 2022 00:40:59 -0700 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dec9e87f8..0414da1da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ - Updated ComposeModal, add max file size and allowed mime types. Fixes #3162. ([879281cc](https://github.com/pixelfed/pixelfed/commit/879281cc)) - Updated profile embeds, fix NaN bug and improve performance. ([3bd211d7](https://github.com/pixelfed/pixelfed/commit/3bd211d7)) - Updated ApiV1Controller, improve follow count cache invalidation. ([4b6effb9](https://github.com/pixelfed/pixelfed/commit/4b6effb9)) +- Updated web routes, fix atom feeds for account usernames containing a dot. ([8c54ab57](https://github.com/pixelfed/pixelfed/commit/8c54ab57)) +- Updated atom feeds, include media alt text. Fixes #3184. ([5d9b6863](https://github.com/pixelfed/pixelfed/commit/5d9b6863)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2) From fea2faaba8b564adca0f2d932984d11810f1616b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 25 Jan 2022 00:50:10 -0700 Subject: [PATCH 4/4] Update compiled assets --- public/js/spa.js | Bin 1510112 -> 1510243 bytes public/mix-manifest.json | Bin 1983 -> 1983 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/js/spa.js b/public/js/spa.js index fbb8a1693570c3fb5cf81a2db0e8c68804912e1d..e728c8e0104dc230e5251ec76f18d5eff25a7f94 100644 GIT binary patch delta 172 zcmaDbHRkcOn1&X{7N!>F7M2#)7Pc1l7LFFq7OocV7M>Q~7QPn#Edu&`MM^RF7M2#)7Pc1l7LFFq7OocV7M>Q~7QPn#Edu&`#ZxtulJj#5 x@{3b-Q&NkwOY#epG-GuPr*E7fEZTl=uK*AW0)8Yt0kpCSr2qf` delta 33 ocmdnbzn_1@Y&H>d()8Yt0k7E!x&QzG