Update atom feed, improve cache expiry and fix double encoding bug. Fixes #4121

This commit is contained in:
Daniel Supernault 2023-03-18 21:45:35 -06:00
parent 3c712a70d6
commit 467c9d754e
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
4 changed files with 11 additions and 4 deletions

View file

@ -207,7 +207,7 @@ class ProfileController extends Controller
abort_if(!$profile || $profile['locked'] || !$profile['local'], 404); abort_if(!$profile || $profile['locked'] || !$profile['local'], 404);
$data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 86400, function() use($pid, $profile) { $data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 43200, function() use($pid, $profile) {
$items = DB::table('statuses') $items = DB::table('statuses')
->whereProfileId($pid) ->whereProfileId($pid)
->whereVisibility('public') ->whereVisibility('public')

View file

@ -2,7 +2,7 @@
namespace App\Jobs\StatusPipeline; namespace App\Jobs\StatusPipeline;
use DB, Storage; use DB, Cache, Storage;
use App\{ use App\{
AccountInterstitial, AccountInterstitial,
Bookmark, Bookmark,
@ -81,6 +81,8 @@ class StatusDelete implements ShouldQueue
} }
} }
Cache::forget('pf:atom:user-feed:by-id:' . $status->profile_id);
if(config_cache('federation.activitypub.enabled') == true) { if(config_cache('federation.activitypub.enabled') == true) {
return $this->fanoutDelete($status); return $this->fanoutDelete($status);
} else { } else {

View file

@ -12,6 +12,7 @@ use App\Services\PublicTimelineService;
use App\Util\Lexer\Autolink; use App\Util\Lexer\Autolink;
use App\Util\Lexer\Extractor; use App\Util\Lexer\Extractor;
use App\Util\Sentiment\Bouncer; use App\Util\Sentiment\Bouncer;
use Cache;
use DB; use DB;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
@ -166,6 +167,8 @@ class StatusEntityLexer implements ShouldQueue
if(config_cache('pixelfed.bouncer.enabled')) { if(config_cache('pixelfed.bouncer.enabled')) {
Bouncer::get($status); Bouncer::get($status);
} }
Cache::forget('pf:atom:user-feed:by-id:' . $status->profile_id);
$hideNsfw = config('instance.hide_nsfw_on_public_feeds'); $hideNsfw = config('instance.hide_nsfw_on_public_feeds');
if( $status->uri == null && if( $status->uri == null &&
$status->scope == 'public' && $status->scope == 'public' &&

View file

@ -24,12 +24,14 @@
</author> </author>
<content type="html"> <content type="html">
<![CDATA[ <![CDATA[
<img id="rss_item_{{$loop->iteration}}" src="{{ $item['media_attachments'][0]['url'] }}" alt="{{ $item['media_attachments'][0]['description'] }}"> <img id="rss_item_{{$item['id']}}" src="{{ $item['media_attachments'][0]['url'] }}" alt="{{ $item['media_attachments'][0]['description'] }}">
<p style="padding:10px;">{{ $item['content'] }}</p> <p style="padding:10px;">{!! $item['content'] !!}</p>
]]> ]]>
</content> </content>
<link rel="alternate" href="{{ $item['url'] }}" /> <link rel="alternate" href="{{ $item['url'] }}" />
@if($item['content'] && strlen($item['content']))
<summary type="html">{{ $item['content'] }}</summary> <summary type="html">{{ $item['content'] }}</summary>
@endif
<media:content url="{{ $item['media_attachments'][0]['url'] }}" type="{{ $item['media_attachments'][0]['mime'] }}" medium="image" /> <media:content url="{{ $item['media_attachments'][0]['url'] }}" type="{{ $item['media_attachments'][0]['mime'] }}" medium="image" />
</entry> </entry>
@endforeach @endforeach