|
|
@ -3018,8 +3018,15 @@ class ApiV1Controller extends Controller
|
|
|
|
->orderByDesc('id')
|
|
|
|
->orderByDesc('id')
|
|
|
|
->cursorPaginate($limit);
|
|
|
|
->cursorPaginate($limit);
|
|
|
|
|
|
|
|
|
|
|
|
$bookmarks = $bookmarkQuery->map(function($bookmark) {
|
|
|
|
$bookmarks = $bookmarkQuery->map(function($bookmark) use($pid) {
|
|
|
|
return \App\Services\StatusService::getMastodon($bookmark->status_id);
|
|
|
|
$status = StatusService::getMastodon($bookmark->status_id, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($status) {
|
|
|
|
|
|
|
|
$status['bookmarked'] = true;
|
|
|
|
|
|
|
|
$status['favourited'] = LikeService::liked($pid, $status['id']);
|
|
|
|
|
|
|
|
$status['reblogged'] = ReblogService::get($pid, $status['id']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
->filter()
|
|
|
|
->filter()
|
|
|
|
->values()
|
|
|
|
->values()
|
|
|
@ -3057,17 +3064,29 @@ class ApiV1Controller extends Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
|
abort_if(!$request->user(), 403);
|
|
|
|
abort_if(!$request->user(), 403);
|
|
|
|
|
|
|
|
|
|
|
|
$status = Status::whereNull('uri')
|
|
|
|
$status = Status::findOrFail($id);
|
|
|
|
->whereScope('public')
|
|
|
|
$pid = $request->user()->profile_id;
|
|
|
|
->findOrFail($id);
|
|
|
|
|
|
|
|
|
|
|
|
abort_if($status->in_reply_to_id || $status->reblog_of_id, 404);
|
|
|
|
|
|
|
|
abort_if(!in_array($status->scope, ['public', 'unlisted', 'private']), 404);
|
|
|
|
|
|
|
|
abort_if(!in_array($status->type, ['photo','photo:album', 'video', 'video:album', 'photo:video:album']), 404);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($status->scope == 'private') {
|
|
|
|
|
|
|
|
abort_if(
|
|
|
|
|
|
|
|
$pid !== $status->profile_id && !FollowerService::follows($pid, $status->profile_id),
|
|
|
|
|
|
|
|
404,
|
|
|
|
|
|
|
|
'Error: You cannot bookmark private posts from accounts you do not follow.'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bookmark::firstOrCreate([
|
|
|
|
Bookmark::firstOrCreate([
|
|
|
|
'status_id' => $status->id,
|
|
|
|
'status_id' => $status->id,
|
|
|
|
'profile_id' => $request->user()->profile_id
|
|
|
|
'profile_id' => $pid
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
BookmarkService::add($request->user()->profile_id, $status->id);
|
|
|
|
BookmarkService::add($pid, $status->id);
|
|
|
|
$res = StatusService::getMastodon($status->id);
|
|
|
|
|
|
|
|
|
|
|
|
$res = StatusService::getMastodon($status->id, false);
|
|
|
|
$res['bookmarked'] = true;
|
|
|
|
$res['bookmarked'] = true;
|
|
|
|
|
|
|
|
|
|
|
|
return $this->json($res);
|
|
|
|
return $this->json($res);
|
|
|
@ -3084,19 +3103,22 @@ class ApiV1Controller extends Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
|
abort_if(!$request->user(), 403);
|
|
|
|
abort_if(!$request->user(), 403);
|
|
|
|
|
|
|
|
|
|
|
|
$status = Status::whereNull('uri')
|
|
|
|
$status = Status::findOrFail($id);
|
|
|
|
->whereScope('public')
|
|
|
|
$pid = $request->user()->profile_id;
|
|
|
|
->findOrFail($id);
|
|
|
|
|
|
|
|
|
|
|
|
abort_if($status->in_reply_to_id || $status->reblog_of_id, 404);
|
|
|
|
|
|
|
|
abort_if(!in_array($status->scope, ['public', 'unlisted', 'private']), 404);
|
|
|
|
|
|
|
|
abort_if(!in_array($status->type, ['photo','photo:album', 'video', 'video:album', 'photo:video:album']), 404);
|
|
|
|
|
|
|
|
|
|
|
|
$bookmark = Bookmark::whereStatusId($status->id)
|
|
|
|
$bookmark = Bookmark::whereStatusId($status->id)
|
|
|
|
->whereProfileId($request->user()->profile_id)
|
|
|
|
->whereProfileId($pid)
|
|
|
|
->first();
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
|
|
if($bookmark) {
|
|
|
|
if($bookmark) {
|
|
|
|
BookmarkService::del($request->user()->profile_id, $status->id);
|
|
|
|
BookmarkService::del($pid, $status->id);
|
|
|
|
$bookmark->delete();
|
|
|
|
$bookmark->delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$res = StatusService::getMastodon($status->id);
|
|
|
|
$res = StatusService::getMastodon($status->id, false);
|
|
|
|
$res['bookmarked'] = false;
|
|
|
|
$res['bookmarked'] = false;
|
|
|
|
|
|
|
|
|
|
|
|
return $this->json($res);
|
|
|
|
return $this->json($res);
|
|
|
|