Browse Source

Merge pull request #4750 from mbliznikova/3698_make_unlisted_photos_visible_in_collections

3698 make unlisted photos visible in collections
daniel 1 year ago
parent
commit
baa653d7de

+ 5 - 5
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);
 

+ 1 - 1
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();

+ 1 - 2
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;
 				});
 			});
 		},