diff --git a/.editorconfig b/.editorconfig index 6b67635e7..1cd7d1077 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,6 +2,7 @@ root = true [*] indent_size = 4 +indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true diff --git a/CHANGELOG.md b/CHANGELOG.md index 89b1762b0..cc056ec21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,6 +104,11 @@ - Update notifications component, improve UX with exponential retry and loading state ([937e6d07](https://github.com/pixelfed/pixelfed/commit/937e6d07)) - Update likeModal and shareModal components, use new pagination logic and re-add Follow/Unfollow buttons ([b565ead6](https://github.com/pixelfed/pixelfed/commit/b565ead6)) - Update profileFeed component, fix pagination ([7cf41628](https://github.com/pixelfed/pixelfed/commit/7cf41628)) +- Update ApiV1Controller, add BookmarkService logic to bookmark endpoints ([29b1af10](https://github.com/pixelfed/pixelfed/commit/29b1af10)) +- Update ApiV1Controller, filter conversations without last_status ([e8a6a8c7](https://github.com/pixelfed/pixelfed/commit/e8a6a8c7)) +- Update ApiV1Controller and BookmarkController, fix api differences and allow unbookmarking regardless of relationship ([e343061a](https://github.com/pixelfed/pixelfed/commit/e343061a)) +- Update ApiV1Controller, add pixelfed entity support to bookmarks endpoint ([94069db9](https://github.com/pixelfed/pixelfed/commit/94069db9)) +- Update PostReactions, reduce bookmark timeout to 2s from 5s ([a8094e6c](https://github.com/pixelfed/pixelfed/commit/a8094e6c)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 8e9e7375b..4447d0753 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2335,7 +2335,7 @@ class ApiV1Controller extends Controller return $res; }) ->filter(function($dm) { - return isset($dm['accounts']) && count($dm['accounts']); + return isset($dm['accounts']) && count($dm['accounts']) && !empty($dm['last_status']); }) ->unique(function($item, $key) { return $item['accounts'][0]['id']; @@ -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); } @@ -3004,6 +3005,7 @@ class ApiV1Controller extends Controller 'min_id' => 'nullable|integer|min:0' ]); + $pe = $request->has('_pe'); $pid = $request->user()->profile_id; $limit = $request->input('limit') ?? 20; $max_id = $request->input('max_id'); @@ -3017,8 +3019,15 @@ class ApiV1Controller extends Controller ->orderByDesc('id') ->cursorPaginate($limit); - $bookmarks = $bookmarkQuery->map(function($bookmark) { - return \App\Services\StatusService::getMastodon($bookmark->status_id); + $bookmarks = $bookmarkQuery->map(function($bookmark) use($pid, $pe) { + $status = $pe ? StatusService::get($bookmark->status_id, false) : 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() ->values() @@ -3056,15 +3065,30 @@ class ApiV1Controller extends Controller { abort_if(!$request->user(), 403); - $status = Status::whereNull('uri') - ->whereScope('public') - ->findOrFail($id); + $status = Status::findOrFail($id); + $pid = $request->user()->profile_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([ 'status_id' => $status->id, - 'profile_id' => $request->user()->profile_id + 'profile_id' => $pid ]); - $res = StatusService::getMastodon($status->id); + + BookmarkService::add($pid, $status->id); + + $res = StatusService::getMastodon($status->id, false); + $res['bookmarked'] = true; return $this->json($res); } @@ -3080,15 +3104,23 @@ class ApiV1Controller extends Controller { abort_if(!$request->user(), 403); - $status = Status::whereNull('uri') - ->whereScope('public') - ->findOrFail($id); + $status = Status::findOrFail($id); + $pid = $request->user()->profile_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) - ->whereProfileId($request->user()->profile_id) - ->firstOrFail(); - $bookmark->delete(); - $res = StatusService::getMastodon($status->id); + ->whereProfileId($pid) + ->first(); + + if($bookmark) { + BookmarkService::del($pid, $status->id); + $bookmark->delete(); + } + $res = StatusService::getMastodon($status->id, false); + $res['bookmarked'] = false; return $this->json($res); } diff --git a/app/Http/Controllers/BookmarkController.php b/app/Http/Controllers/BookmarkController.php index f5f59457b..a24520d64 100644 --- a/app/Http/Controllers/BookmarkController.php +++ b/app/Http/Controllers/BookmarkController.php @@ -11,47 +11,57 @@ use App\Services\FollowerService; class BookmarkController extends Controller { - public function __construct() - { - $this->middleware('auth'); - } + public function __construct() + { + $this->middleware('auth'); + } - public function store(Request $request) - { - $this->validate($request, [ - 'item' => 'required|integer|min:1', - ]); + public function store(Request $request) + { + $this->validate($request, [ + 'item' => 'required|integer|min:1', + ]); - $profile = Auth::user()->profile; - $status = Status::findOrFail($request->input('item')); + $profile = Auth::user()->profile; + $status = Status::findOrFail($request->input('item')); - abort_if(!in_array($status->scope, ['public', 'unlisted', 'private']), 404); + 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( - $profile->id !== $status->profile_id && !FollowerService::follows($profile->id, $status->profile_id), - 404, - 'Error: You cannot bookmark private posts from accounts you do not follow.' - ); - } + if($status->scope == 'private') { + if($profile->id !== $status->profile_id && !FollowerService::follows($profile->id, $status->profile_id)) { + if($exists = Bookmark::whereStatusId($status->id)->whereProfileId($profile->id)->first()) { + BookmarkService::del($profile->id, $status->id); + $exists->delete(); - $bookmark = Bookmark::firstOrCreate( - ['status_id' => $status->id], ['profile_id' => $profile->id] - ); + if ($request->ajax()) { + return ['code' => 200, 'msg' => 'Bookmark removed!']; + } else { + return redirect()->back(); + } + } + abort(404, 'Error: You cannot bookmark private posts from accounts you do not follow.'); + } + } - if (!$bookmark->wasRecentlyCreated) { - BookmarkService::del($profile->id, $status->id); - $bookmark->delete(); - } else { - BookmarkService::add($profile->id, $status->id); - } + $bookmark = Bookmark::firstOrCreate( + ['status_id' => $status->id], ['profile_id' => $profile->id] + ); - if ($request->ajax()) { - $response = ['code' => 200, 'msg' => 'Bookmark saved!']; - } else { - $response = redirect()->back(); - } + if (!$bookmark->wasRecentlyCreated) { + BookmarkService::del($profile->id, $status->id); + $bookmark->delete(); + } else { + BookmarkService::add($profile->id, $status->id); + } - return $response; - } + if ($request->ajax()) { + $response = ['code' => 200, 'msg' => 'Bookmark saved!']; + } else { + $response = redirect()->back(); + } + + return $response; + } } diff --git a/public/js/daci.chunk.232f6f724c527858.js b/public/js/daci.chunk.289add6be0f9f34f.js similarity index 67% rename from public/js/daci.chunk.232f6f724c527858.js rename to public/js/daci.chunk.289add6be0f9f34f.js index 75323bb40..74941a97a 100644 Binary files a/public/js/daci.chunk.232f6f724c527858.js and b/public/js/daci.chunk.289add6be0f9f34f.js differ diff --git a/public/js/discover~findfriends.chunk.e3a7e0813bc9e3ec.js b/public/js/discover~findfriends.chunk.f9f303e4742d4d0e.js similarity index 66% rename from public/js/discover~findfriends.chunk.e3a7e0813bc9e3ec.js rename to public/js/discover~findfriends.chunk.f9f303e4742d4d0e.js index 15e26d0ba..7184962ff 100644 Binary files a/public/js/discover~findfriends.chunk.e3a7e0813bc9e3ec.js and b/public/js/discover~findfriends.chunk.f9f303e4742d4d0e.js differ diff --git a/public/js/discover~memories.chunk.487c14a0180fbf85.js b/public/js/discover~memories.chunk.b6fd5951cd01560a.js similarity index 67% rename from public/js/discover~memories.chunk.487c14a0180fbf85.js rename to public/js/discover~memories.chunk.b6fd5951cd01560a.js index 6fb790074..9777bdaae 100644 Binary files a/public/js/discover~memories.chunk.487c14a0180fbf85.js and b/public/js/discover~memories.chunk.b6fd5951cd01560a.js differ diff --git a/public/js/discover~myhashtags.chunk.075cc9fe49783f65.js b/public/js/discover~myhashtags.chunk.ec2c96b72899819b.js similarity index 73% rename from public/js/discover~myhashtags.chunk.075cc9fe49783f65.js rename to public/js/discover~myhashtags.chunk.ec2c96b72899819b.js index 1b65bf6c8..2ebfa1245 100644 Binary files a/public/js/discover~myhashtags.chunk.075cc9fe49783f65.js and b/public/js/discover~myhashtags.chunk.ec2c96b72899819b.js differ diff --git a/public/js/discover~serverfeed.chunk.c37e8a7a49d49297.js b/public/js/discover~serverfeed.chunk.556f2541edd05a9c.js similarity index 67% rename from public/js/discover~serverfeed.chunk.c37e8a7a49d49297.js rename to public/js/discover~serverfeed.chunk.556f2541edd05a9c.js index 1695859f0..6b87251f6 100644 Binary files a/public/js/discover~serverfeed.chunk.c37e8a7a49d49297.js and b/public/js/discover~serverfeed.chunk.556f2541edd05a9c.js differ diff --git a/public/js/discover~settings.chunk.ddc15c2d10514bf9.js b/public/js/discover~settings.chunk.9bac38bba3619276.js similarity index 68% rename from public/js/discover~settings.chunk.ddc15c2d10514bf9.js rename to public/js/discover~settings.chunk.9bac38bba3619276.js index 4759f63c2..951ddd2da 100644 Binary files a/public/js/discover~settings.chunk.ddc15c2d10514bf9.js and b/public/js/discover~settings.chunk.9bac38bba3619276.js differ diff --git a/public/js/home.chunk.294faaa69171455b.js b/public/js/home.chunk.64a8f34f10a4fa8b.js similarity index 68% rename from public/js/home.chunk.294faaa69171455b.js rename to public/js/home.chunk.64a8f34f10a4fa8b.js index e31ea1e5e..d753edc31 100644 Binary files a/public/js/home.chunk.294faaa69171455b.js and b/public/js/home.chunk.64a8f34f10a4fa8b.js differ diff --git a/public/js/manifest.js b/public/js/manifest.js index 55dce5ee8..7e90b245b 100644 Binary files a/public/js/manifest.js and b/public/js/manifest.js differ diff --git a/public/js/post.chunk.dffb139831cf2ae9.js b/public/js/post.chunk.d7408f11b67053fd.js similarity index 70% rename from public/js/post.chunk.dffb139831cf2ae9.js rename to public/js/post.chunk.d7408f11b67053fd.js index 8f10d000d..3ae1ef0c3 100644 Binary files a/public/js/post.chunk.dffb139831cf2ae9.js and b/public/js/post.chunk.d7408f11b67053fd.js differ diff --git a/public/js/profile.chunk.99838eb369862e91.js b/public/js/profile.chunk.99838eb369862e91.js deleted file mode 100644 index 26cd2b70a..000000000 Binary files a/public/js/profile.chunk.99838eb369862e91.js and /dev/null differ diff --git a/public/js/profile.chunk.e6ac60336120dcd5.js b/public/js/profile.chunk.e6ac60336120dcd5.js new file mode 100644 index 000000000..ddbb03983 Binary files /dev/null and b/public/js/profile.chunk.e6ac60336120dcd5.js differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 4101c4f46..a43856c27 100644 Binary files a/public/mix-manifest.json and b/public/mix-manifest.json differ diff --git a/resources/assets/components/partials/post/PostReactions.vue b/resources/assets/components/partials/post/PostReactions.vue new file mode 100644 index 000000000..5456b7e63 --- /dev/null +++ b/resources/assets/components/partials/post/PostReactions.vue @@ -0,0 +1,251 @@ + + + diff --git a/resources/assets/components/partials/profile/ProfileFeed.vue b/resources/assets/components/partials/profile/ProfileFeed.vue new file mode 100644 index 000000000..3be99ce38 --- /dev/null +++ b/resources/assets/components/partials/profile/ProfileFeed.vue @@ -0,0 +1,1165 @@ + + + + +