mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-12 17:44:31 +00:00
Update liked by, fix remote username urls
This commit is contained in:
parent
d496a48574
commit
f767d99ad5
4 changed files with 22 additions and 5 deletions
|
@ -199,8 +199,15 @@ class PublicApiController extends Controller
|
||||||
|
|
||||||
public function statusLikes(Request $request, $username, $id)
|
public function statusLikes(Request $request, $username, $id)
|
||||||
{
|
{
|
||||||
|
abort_if(!$request->user(), 404);
|
||||||
$status = Status::findOrFail($id);
|
$status = Status::findOrFail($id);
|
||||||
$this->scopeCheck($status->profile, $status);
|
$this->scopeCheck($status->profile, $status);
|
||||||
|
$page = $request->input('page');
|
||||||
|
if($page && $page >= 3 && $request->user()->profile_id != $status->profile_id) {
|
||||||
|
return response()->json([
|
||||||
|
'data' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
$likes = $this->getLikes($status);
|
$likes = $this->getLikes($status);
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'data' => $likes
|
'data' => $likes
|
||||||
|
@ -209,9 +216,16 @@ class PublicApiController extends Controller
|
||||||
|
|
||||||
public function statusShares(Request $request, $username, $id)
|
public function statusShares(Request $request, $username, $id)
|
||||||
{
|
{
|
||||||
|
abort_if(!$request->user(), 404);
|
||||||
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
||||||
$status = Status::whereProfileId($profile->id)->findOrFail($id);
|
$status = Status::whereProfileId($profile->id)->findOrFail($id);
|
||||||
$this->scopeCheck($profile, $status);
|
$this->scopeCheck($profile, $status);
|
||||||
|
$page = $request->input('page');
|
||||||
|
if($page && $page >= 3 && $request->user()->profile_id != $status->profile_id) {
|
||||||
|
return response()->json([
|
||||||
|
'data' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
$shares = $this->getShares($status);
|
$shares = $this->getShares($status);
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'data' => $shares
|
'data' => $shares
|
||||||
|
|
|
@ -71,13 +71,16 @@ class LikeService {
|
||||||
|
|
||||||
$id = $like->profile_id;
|
$id = $like->profile_id;
|
||||||
|
|
||||||
|
$profile = ProfileService::get($id);
|
||||||
|
$profileUrl = $profile['local'] ? $profile['url'] : '/i/web/profile/_/' . $profile['id'];
|
||||||
$res = [
|
$res = [
|
||||||
'username' => ProfileService::get($id)['username'],
|
'username' => $profile['username'],
|
||||||
'others' => $status->likes_count >= 5,
|
'url' => $profileUrl,
|
||||||
|
'others' => $status->likes_count >= 3,
|
||||||
];
|
];
|
||||||
|
|
||||||
if(request()->user() && request()->user()->profile_id == $status->profile_id) {
|
if(request()->user() && request()->user()->profile_id == $status->profile_id) {
|
||||||
$res['total_count'] = $status->likes_count;
|
$res['total_count'] = ($status->likes_count - 1);
|
||||||
$res['total_count_pretty'] = number_format($res['total_count']);
|
$res['total_count_pretty'] = number_format($res['total_count']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@
|
||||||
<div class="reaction-counts mb-0">
|
<div class="reaction-counts mb-0">
|
||||||
<div v-if="status.liked_by.username && status.liked_by.username !== user.username" class="likes mb-1">
|
<div v-if="status.liked_by.username && status.liked_by.username !== user.username" class="likes mb-1">
|
||||||
<span class="like-count">Liked by
|
<span class="like-count">Liked by
|
||||||
<a class="font-weight-bold text-dark" :href="'/'+status.liked_by.username">{{status.liked_by.username}}</a>
|
<a class="font-weight-bold text-dark" :href="status.liked_by.url">{{status.liked_by.username}}</a>
|
||||||
<span v-if="status.liked_by.others == true">
|
<span v-if="status.liked_by.others == true">
|
||||||
and <span class="font-weight-bold text-dark cursor-pointer" @click="likesModal"><span v-if="status.liked_by.total_count_pretty">{{status.liked_by.total_count_pretty}}</span> others</span>
|
and <span class="font-weight-bold text-dark cursor-pointer" @click="likesModal"><span v-if="status.liked_by.total_count_pretty">{{status.liked_by.total_count_pretty}}</span> others</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -226,7 +226,7 @@
|
||||||
|
|
||||||
<div v-if="status.liked_by.username && status.liked_by.username !== profile.username" class="likes mb-1">
|
<div v-if="status.liked_by.username && status.liked_by.username !== profile.username" class="likes mb-1">
|
||||||
<span class="like-count">Liked by
|
<span class="like-count">Liked by
|
||||||
<a class="font-weight-bold text-dark" :href="'/'+status.liked_by.username">{{status.liked_by.username}}</a>
|
<a class="font-weight-bold text-dark" :href="status.liked_by.url">{{status.liked_by.username}}</a>
|
||||||
<span v-if="status.liked_by.others == true">
|
<span v-if="status.liked_by.others == true">
|
||||||
and <span class="font-weight-bold" v-if="status.liked_by.total_count_pretty">{{status.liked_by.total_count_pretty}}</span> <span class="font-weight-bold">others</span>
|
and <span class="font-weight-bold" v-if="status.liked_by.total_count_pretty">{{status.liked_by.total_count_pretty}}</span> <span class="font-weight-bold">others</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in a new issue