mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update StatusService, add non-public option and improve cache invalidation
This commit is contained in:
parent
ee0028bc57
commit
15c4fdd90c
2 changed files with 355 additions and 349 deletions
|
@ -21,10 +21,14 @@ class StatusService {
|
|||
return self::CACHE_KEY . $id;
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
public static function get($id, $publicOnly = true)
|
||||
{
|
||||
return Cache::remember(self::key($id), now()->addDays(7), function() use($id) {
|
||||
return Cache::remember(self::key($id), now()->addDays(7), function() use($id, $publicOnly) {
|
||||
if($publicOnly) {
|
||||
$status = Status::whereScope('public')->find($id);
|
||||
} else {
|
||||
$status = Status::whereIn('scope', ['public', 'private', 'unlisted'])->find($id);
|
||||
}
|
||||
if(!$status) {
|
||||
return null;
|
||||
}
|
||||
|
@ -37,6 +41,8 @@ class StatusService {
|
|||
|
||||
public static function del($id)
|
||||
{
|
||||
Cache::forget('pf:services:sh:id:' . $id);
|
||||
Cache::forget('status:transformer:media:attachments:' . $id);
|
||||
PublicTimelineService::rem($id);
|
||||
return Cache::forget(self::key($id));
|
||||
}
|
||||
|
|
|
@ -101,10 +101,10 @@ class Status extends Model
|
|||
});
|
||||
}
|
||||
|
||||
public function url()
|
||||
public function url($forceLocal = false)
|
||||
{
|
||||
if($this->uri) {
|
||||
return $this->uri;
|
||||
return $forceLocal ? "/i/web/post/_/{$this->profile_id}/{$this->id}" : $this->uri;
|
||||
} else {
|
||||
$id = $this->id;
|
||||
$username = $this->profile->username;
|
||||
|
|
Loading…
Reference in a new issue