From 2c6edf37a7363e863756b6139d413ae5ab560f4c Mon Sep 17 00:00:00 2001 From: mbliznikova Date: Thu, 9 Nov 2023 18:27:24 +0000 Subject: [PATCH] oFix #3698, make unlisted photos visible in collections --- app/Http/Controllers/CollectionController.php | 10 +++++----- resources/assets/js/components/CollectionComponent.vue | 2 +- resources/assets/js/components/CollectionCompose.vue | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index 6cd4bda57..46dcf4838 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -153,7 +153,7 @@ class CollectionController extends Controller abort(400, 'You can only add '.$max.' posts per collection'); } - $status = Status::whereScope('public') + $status = Status::whereIn('scope', ['public', 'unlisted']) ->whereProfileId($profileId) ->whereIn('type', ['photo', 'photo:album', 'video']) ->findOrFail($postId); @@ -176,7 +176,7 @@ class CollectionController extends Controller $collection->save(); CollectionService::setCollection($collection->id, $collection); - return StatusService::get($status->id); + return StatusService::get($status->id, false); } public function getCollection(Request $request, $id) @@ -226,10 +226,10 @@ class CollectionController extends Controller return collect($items) ->map(function($id) { - return StatusService::get($id); + return StatusService::get($id, false); }) ->filter(function($item) { - return $item && isset($item['account'], $item['media_attachments']); + return $item && ($item['visibility'] == 'public' || $item['visibility'] == 'unlisted') && isset($item['account'], $item['media_attachments']); }) ->values(); } @@ -298,7 +298,7 @@ class CollectionController extends Controller abort(400, 'You cannot delete the only post of a collection!'); } - $status = Status::whereScope('public') + $status = Status::whereIn('scope', ['public', 'unlisted']) ->whereIn('type', ['photo', 'photo:album', 'video']) ->findOrFail($postId); diff --git a/resources/assets/js/components/CollectionComponent.vue b/resources/assets/js/components/CollectionComponent.vue index 3f77cfc13..60510f559 100644 --- a/resources/assets/js/components/CollectionComponent.vue +++ b/resources/assets/js/components/CollectionComponent.vue @@ -460,7 +460,7 @@ export default { }) .then(res => { self.postsList = res.data.filter(l => { - return self.ids.indexOf(l.id) == -1; + return (l.visibility == 'public' || l.visibility == 'unlisted') && l.sensitive == false && self.ids.indexOf(l.id) == -1; }); self.loadingPostList = false; self.$refs.addPhotoModal.show(); diff --git a/resources/assets/js/components/CollectionCompose.vue b/resources/assets/js/components/CollectionCompose.vue index 84444cf1d..2920e1f76 100644 --- a/resources/assets/js/components/CollectionCompose.vue +++ b/resources/assets/js/components/CollectionCompose.vue @@ -194,7 +194,6 @@ export default { swal('Invalid URL', 'You can only add posts from this instance', 'error'); this.id = ''; } - if(url.includes('/i/web/post/') || url.includes('/p/')) { let id = split[split.length - 1]; console.log('adding ' + id); @@ -228,7 +227,7 @@ export default { let ids = this.posts.map(s => { return s.id; }); - return s.visibility == 'public' && s.sensitive == false && ids.indexOf(s.id) == -1; + return (s.visibility == 'public' || s.visibility == 'unlisted') && s.sensitive == false && ids.indexOf(s.id) == -1; }); }); },