mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-22 12:30:46 +00:00
Merge pull request #2658 from pixelfed/staging
Updated Status model, refactor liked and shared methods to fix cache invalidation bug
This commit is contained in:
commit
0d7aee0e21
2 changed files with 16 additions and 14 deletions
|
@ -43,6 +43,7 @@
|
||||||
- Updated Embeds. Fix Profile + Status embeds, remove following count and improve cache invalidation and hidden follower counts. ([5ac9d0e8](https://github.com/pixelfed/pixelfed/commit/5ac9d0e8))
|
- Updated Embeds. Fix Profile + Status embeds, remove following count and improve cache invalidation and hidden follower counts. ([5ac9d0e8](https://github.com/pixelfed/pixelfed/commit/5ac9d0e8))
|
||||||
- Updated FederationController, return 404 for invalid webfinger addresses. Fixes ([#2647](https://github.com/pixelfed/pixelfed/issues/2647)). ([deb6f115](https://github.com/pixelfed/pixelfed/commit/deb6f115))
|
- Updated FederationController, return 404 for invalid webfinger addresses. Fixes ([#2647](https://github.com/pixelfed/pixelfed/issues/2647)). ([deb6f115](https://github.com/pixelfed/pixelfed/commit/deb6f115))
|
||||||
- Updated InboxPipeline, fail earlier for invalid public keys. Fixes ([#2648](https://github.com/pixelfed/pixelfed/issues/2648)). ([d1c5e9b8](https://github.com/pixelfed/pixelfed/commit/d1c5e9b8))
|
- Updated InboxPipeline, fail earlier for invalid public keys. Fixes ([#2648](https://github.com/pixelfed/pixelfed/issues/2648)). ([d1c5e9b8](https://github.com/pixelfed/pixelfed/commit/d1c5e9b8))
|
||||||
|
- Updated Status model, refactor liked and shared methods to fix cache invalidation bug. ([f05c3b66](https://github.com/pixelfed/pixelfed/commit/f05c3b66))
|
||||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||||
|
|
||||||
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)
|
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)
|
||||||
|
|
|
@ -144,15 +144,16 @@ class Status extends Model
|
||||||
|
|
||||||
public function liked() : bool
|
public function liked() : bool
|
||||||
{
|
{
|
||||||
if(Auth::check() == false) {
|
if(!Auth::check()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$user = Auth::user();
|
|
||||||
$id = $this->id;
|
$pid = Auth::user()->profile_id;
|
||||||
return Cache::remember('status:'.$this->id.':likedby:userid:'.$user->id, now()->addHours(30), function() use($user, $id) {
|
|
||||||
$profile = $user->profile;
|
return Like::select('status_id', 'profile_id')
|
||||||
return Like::whereProfileId($profile->id)->whereStatusId($id)->count();
|
->whereStatusId($this->id)
|
||||||
});
|
->whereProfileId($pid)
|
||||||
|
->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function likedBy()
|
public function likedBy()
|
||||||
|
@ -189,15 +190,15 @@ class Status extends Model
|
||||||
|
|
||||||
public function shared() : bool
|
public function shared() : bool
|
||||||
{
|
{
|
||||||
if(Auth::check() == false) {
|
if(!Auth::check()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$user = Auth::user();
|
$pid = Auth::user()->profile_id;
|
||||||
$id = $this->id;
|
|
||||||
return Cache::remember('status:'.$this->id.':sharedby:userid:'.$user->id, now()->addHours(30), function() use($user, $id) {
|
return $this->select('profile_id', 'reblog_of_id')
|
||||||
$profile = $user->profile;
|
->whereProfileId($pid)
|
||||||
return self::whereProfileId($profile->id)->whereReblogOfId($id)->count();
|
->whereReblogOfId($this->id)
|
||||||
});
|
->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sharedBy()
|
public function sharedBy()
|
||||||
|
|
Loading…
Reference in a new issue