Merge pull request #4795 from pixelfed/staging

Staging
This commit is contained in:
daniel 2023-12-05 00:50:51 -07:00 committed by GitHub
commit f9badbf4dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 232 additions and 228 deletions

View File

@ -153,7 +153,7 @@ class CollectionController extends Controller
abort(400, 'You can only add '.$max.' posts per collection'); abort(400, 'You can only add '.$max.' posts per collection');
} }
$status = Status::whereScope('public') $status = Status::whereIn('scope', ['public', 'unlisted'])
->whereProfileId($profileId) ->whereProfileId($profileId)
->whereIn('type', ['photo', 'photo:album', 'video']) ->whereIn('type', ['photo', 'photo:album', 'video'])
->findOrFail($postId); ->findOrFail($postId);
@ -166,17 +166,13 @@ class CollectionController extends Controller
'order' => $count, 'order' => $count,
]); ]);
CollectionService::addItem( CollectionService::deleteCollection($collection->id);
$collection->id,
$status->id,
$count
);
$collection->updated_at = now(); $collection->updated_at = now();
$collection->save(); $collection->save();
CollectionService::setCollection($collection->id, $collection); CollectionService::setCollection($collection->id, $collection);
return StatusService::get($status->id); return StatusService::get($status->id, false);
} }
public function getCollection(Request $request, $id) public function getCollection(Request $request, $id)
@ -226,10 +222,10 @@ class CollectionController extends Controller
return collect($items) return collect($items)
->map(function($id) { ->map(function($id) {
return StatusService::get($id); return StatusService::get($id, false);
}) })
->filter(function($item) { ->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(); ->values();
} }
@ -298,7 +294,7 @@ class CollectionController extends Controller
abort(400, 'You cannot delete the only post of a collection!'); 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']) ->whereIn('type', ['photo', 'photo:album', 'video'])
->findOrFail($postId); ->findOrFail($postId);

View File

@ -30,6 +30,7 @@ use App\Util\ActivityPub\{
}; };
use Zttp\Zttp; use Zttp\Zttp;
use App\Services\InstanceService; use App\Services\InstanceService;
use App\Services\AccountService;
class FederationController extends Controller class FederationController extends Controller
{ {
@ -239,12 +240,15 @@ class FederationController extends Controller
{ {
abort_if(!config_cache('federation.activitypub.enabled'), 404); abort_if(!config_cache('federation.activitypub.enabled'), 404);
$id = AccountService::usernameToId($username);
abort_if(!$id, 404);
$account = AccountService::get($id);
abort_if(!$account || !isset($account['following_count']), 404);
$obj = [ $obj = [
'@context' => 'https://www.w3.org/ns/activitystreams', '@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $request->getUri(), 'id' => $request->getUri(),
'type' => 'OrderedCollectionPage', 'type' => 'OrderedCollection',
'totalItems' => 0, 'totalItems' => $account['following_count'] ?? 0,
'orderedItems' => []
]; ];
return response()->json($obj); return response()->json($obj);
} }
@ -252,15 +256,16 @@ class FederationController extends Controller
public function userFollowers(Request $request, $username) public function userFollowers(Request $request, $username)
{ {
abort_if(!config_cache('federation.activitypub.enabled'), 404); abort_if(!config_cache('federation.activitypub.enabled'), 404);
$id = AccountService::usernameToId($username);
abort_if(!$id, 404);
$account = AccountService::get($id);
abort_if(!$account || !isset($account['followers_count']), 404);
$obj = [ $obj = [
'@context' => 'https://www.w3.org/ns/activitystreams', '@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $request->getUri(), 'id' => $request->getUri(),
'type' => 'OrderedCollectionPage', 'type' => 'OrderedCollection',
'totalItems' => 0, 'totalItems' => $account['followers_count'] ?? 0,
'orderedItems' => []
]; ];
return response()->json($obj); return response()->json($obj);
} }
} }

View File

@ -33,7 +33,7 @@ RUN apt-get update \
# Required for GD # Required for GD
libxpm4 \ libxpm4 \
libxpm-dev \ libxpm-dev \
libwebp6 \ libwebp7 \
libwebp-dev \ libwebp-dev \
## Video Processing ## Video Processing
ffmpeg \ ffmpeg \

View File

@ -33,7 +33,7 @@ RUN apt-get update \
# Required for GD # Required for GD
libxpm4 \ libxpm4 \
libxpm-dev \ libxpm-dev \
libwebp6 \ libwebp7 \
libwebp-dev \ libwebp-dev \
## Video Processing ## Video Processing
ffmpeg \ ffmpeg \

View File

@ -460,7 +460,7 @@ export default {
}) })
.then(res => { .then(res => {
self.postsList = res.data.filter(l => { 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.loadingPostList = false;
self.$refs.addPhotoModal.show(); self.$refs.addPhotoModal.show();
@ -619,6 +619,9 @@ export default {
this.posts = this.posts.filter(post => { this.posts = this.posts.filter(post => {
return post.id != id; return post.id != id;
}); });
this.ids = this.ids.filter(post_id => {
return post_id != id;
});
}, },
addRecentId(post) { addRecentId(post) {
@ -630,6 +633,7 @@ export default {
// window.location.reload(); // window.location.reload();
this.closeModals(); this.closeModals();
this.posts.push(res.data); this.posts.push(res.data);
this.ids.push(post.id);
this.collection.post_count++; this.collection.post_count++;
}).catch(err => { }).catch(err => {
swal('Oops!', 'An error occured, please try selecting another post.', 'error'); swal('Oops!', 'An error occured, please try selecting another post.', 'error');

View File

@ -194,7 +194,6 @@ export default {
swal('Invalid URL', 'You can only add posts from this instance', 'error'); swal('Invalid URL', 'You can only add posts from this instance', 'error');
this.id = ''; this.id = '';
} }
if(url.includes('/i/web/post/') || url.includes('/p/')) { if(url.includes('/i/web/post/') || url.includes('/p/')) {
let id = split[split.length - 1]; let id = split[split.length - 1];
console.log('adding ' + id); console.log('adding ' + id);
@ -228,7 +227,7 @@ export default {
let ids = this.posts.map(s => { let ids = this.posts.map(s => {
return s.id; 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;
}); });
}); });
}, },