forked from mirror/pixelfed
Update ApiV1Controller, add BookmarkService logic to bookmark endpoints
This commit is contained in:
parent
2b77ab5990
commit
29b1af100c
1 changed files with 11 additions and 2 deletions
|
@ -2376,6 +2376,7 @@ class ApiV1Controller extends Controller
|
|||
|
||||
$res['favourited'] = LikeService::liked($user->profile_id, $res['id']);
|
||||
$res['reblogged'] = ReblogService::get($user->profile_id, $res['id']);
|
||||
$res['bookmarked'] = BookmarkService::get($user->profile_id, $res['id']);
|
||||
|
||||
return $this->json($res);
|
||||
}
|
||||
|
@ -3064,7 +3065,10 @@ class ApiV1Controller extends Controller
|
|||
'status_id' => $status->id,
|
||||
'profile_id' => $request->user()->profile_id
|
||||
]);
|
||||
|
||||
BookmarkService::add($request->user()->profile_id, $status->id);
|
||||
$res = StatusService::getMastodon($status->id);
|
||||
$res['bookmarked'] = true;
|
||||
|
||||
return $this->json($res);
|
||||
}
|
||||
|
@ -3086,9 +3090,14 @@ class ApiV1Controller extends Controller
|
|||
|
||||
$bookmark = Bookmark::whereStatusId($status->id)
|
||||
->whereProfileId($request->user()->profile_id)
|
||||
->firstOrFail();
|
||||
$bookmark->delete();
|
||||
->first();
|
||||
|
||||
if($bookmark) {
|
||||
BookmarkService::del($request->user()->profile_id, $status->id);
|
||||
$bookmark->delete();
|
||||
}
|
||||
$res = StatusService::getMastodon($status->id);
|
||||
$res['bookmarked'] = false;
|
||||
|
||||
return $this->json($res);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue