mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 05:23:17 +00:00
commit
33eecb46e9
22 changed files with 29 additions and 36 deletions
|
@ -62,7 +62,7 @@
|
|||
- Updated ProfileController, redirect profile view for authed users to Metro 2.0 UI. ([7f8129a7](https://github.com/pixelfed/pixelfed/commit/7f8129a7))
|
||||
- Updated SpaController, fix variable typo. Fixes #3268. ([8d1af1d6](https://github.com/pixelfed/pixelfed/commit/8d1af1d6))
|
||||
- Updated ComposeModal, fix post redirect on old UI. ([160e32a5](https://github.com/pixelfed/pixelfed/commit/160e32a5))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
- Updated LikeService, improve caching logic and add profile id to likedBy method to fix #3271. ([6af842eb](https://github.com/pixelfed/pixelfed/commit/6af842eb))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)
|
||||
|
|
|
@ -14,22 +14,23 @@ class LikeService {
|
|||
public static function add($profileId, $statusId)
|
||||
{
|
||||
$key = self::CACHE_KEY . $profileId . ':' . $statusId;
|
||||
$ttl = now()->addHours(2);
|
||||
return Cache::put($key, true, $ttl);
|
||||
Cache::increment('pf:services:likes:count:'.$statusId);
|
||||
Cache::forget('pf:services:likes:liked_by:'.$statusId);
|
||||
return Cache::put($key, true, 86400);
|
||||
}
|
||||
|
||||
public static function remove($profileId, $statusId)
|
||||
{
|
||||
$key = self::CACHE_KEY . $profileId . ':' . $statusId;
|
||||
$ttl = now()->addHours(2);
|
||||
return Cache::put($key, false, $ttl);
|
||||
Cache::decrement('pf:services:likes:count:'.$statusId);
|
||||
Cache::forget('pf:services:likes:liked_by:'.$statusId);
|
||||
return Cache::put($key, false, 86400);
|
||||
}
|
||||
|
||||
public static function liked($profileId, $statusId)
|
||||
{
|
||||
$key = self::CACHE_KEY . $profileId . ':' . $statusId;
|
||||
$ttl = now()->addMinutes(30);
|
||||
return Cache::remember($key, $ttl, function() use($profileId, $statusId) {
|
||||
return Cache::remember($key, 86400, function() use($profileId, $statusId) {
|
||||
return Like::whereProfileId($profileId)->whereStatusId($statusId)->exists();
|
||||
});
|
||||
}
|
||||
|
@ -45,44 +46,36 @@ class LikeService {
|
|||
return $empty;
|
||||
}
|
||||
|
||||
if(!$status->likes_count) {
|
||||
return $empty;
|
||||
}
|
||||
$user = request()->user();
|
||||
$res = Cache::remember('pf:services:likes:liked_by:' . $status->id, 86400, function() use($status, $empty) {
|
||||
$like = Like::whereStatusId($status->id)->first();
|
||||
if(!$like) {
|
||||
return $empty;
|
||||
}
|
||||
$id = $like->profile_id;
|
||||
$profile = ProfileService::get($id);
|
||||
$profileUrl = "/i/web/profile/{$profile['id']}";
|
||||
$res = [
|
||||
'id' => (string) $profile['id'],
|
||||
'username' => $profile['username'],
|
||||
'url' => $profileUrl,
|
||||
'others' => $status->likes_count >= 3,
|
||||
];
|
||||
return $res;
|
||||
});
|
||||
|
||||
if($user) {
|
||||
$like = Like::whereStatusId($status->id)
|
||||
->where('profile_id', '!=', $user->profile_id)
|
||||
->first();
|
||||
} else {
|
||||
$like = Like::whereStatusId($status->id)
|
||||
->first();
|
||||
}
|
||||
|
||||
if(!$like) {
|
||||
if(!isset($res['id']) || !isset($res['url'])) {
|
||||
return $empty;
|
||||
}
|
||||
|
||||
$id = $like->profile_id;
|
||||
|
||||
$profile = ProfileService::get($id);
|
||||
$profileUrl = $profile['local'] ? $profile['url'] : '/i/web/profile/_/' . $profile['id'];
|
||||
$res = [
|
||||
'username' => $profile['username'],
|
||||
'url' => $profileUrl,
|
||||
'others' => $status->likes_count >= 3,
|
||||
];
|
||||
|
||||
if(request()->user() && request()->user()->profile_id == $status->profile_id) {
|
||||
$res['total_count'] = ($status->likes_count - 1);
|
||||
$res['total_count_pretty'] = number_format($res['total_count']);
|
||||
}
|
||||
$res['total_count'] = ($status->likes_count - 1);
|
||||
$res['total_count_pretty'] = number_format($res['total_count']);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function count($id)
|
||||
{
|
||||
return Like::whereStatusId($id)->count();
|
||||
return Cache::get('pf:services:likes:count:'.$id, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
public/js/dffc-chunk-1rptst.js
vendored
Normal file
BIN
public/js/dffc-chunk-1rptst.js
vendored
Normal file
Binary file not shown.
BIN
public/js/dffc-chunk.js
vendored
BIN
public/js/dffc-chunk.js
vendored
Binary file not shown.
BIN
public/js/dmyh-chunk-1rptst.js
vendored
Normal file
BIN
public/js/dmyh-chunk-1rptst.js
vendored
Normal file
Binary file not shown.
BIN
public/js/dmyh-chunk.js
vendored
BIN
public/js/dmyh-chunk.js
vendored
Binary file not shown.
BIN
public/js/dmym-chunk-1rptst.js
vendored
Normal file
BIN
public/js/dmym-chunk-1rptst.js
vendored
Normal file
Binary file not shown.
BIN
public/js/dmym-chunk.js
vendored
BIN
public/js/dmym-chunk.js
vendored
Binary file not shown.
Binary file not shown.
BIN
public/js/dssc-chunk-1rptst.js
vendored
Normal file
BIN
public/js/dssc-chunk-1rptst.js
vendored
Normal file
Binary file not shown.
BIN
public/js/dssc-chunk.js
vendored
BIN
public/js/dssc-chunk.js
vendored
Binary file not shown.
BIN
public/js/home-chunk-1rptst.js
vendored
Normal file
BIN
public/js/home-chunk-1rptst.js
vendored
Normal file
Binary file not shown.
BIN
public/js/home-chunk.js
vendored
BIN
public/js/home-chunk.js
vendored
Binary file not shown.
BIN
public/js/manifest.js
vendored
BIN
public/js/manifest.js
vendored
Binary file not shown.
BIN
public/js/post-chunk-1rptst.js
vendored
Normal file
BIN
public/js/post-chunk-1rptst.js
vendored
Normal file
Binary file not shown.
BIN
public/js/post-chunk.js
vendored
BIN
public/js/post-chunk.js
vendored
Binary file not shown.
BIN
public/js/profile-chunk-1rptst.js
vendored
Normal file
BIN
public/js/profile-chunk-1rptst.js
vendored
Normal file
Binary file not shown.
BIN
public/js/profile-chunk.js
vendored
BIN
public/js/profile-chunk.js
vendored
Binary file not shown.
BIN
public/js/spa.js
vendored
BIN
public/js/spa.js
vendored
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue