refactor: shared collection controller

This commit is contained in:
Sonny
2025-08-21 02:24:11 +02:00
parent 87ced07d20
commit 5f7fad26fa
2 changed files with 18 additions and 51 deletions

View File

@@ -61,7 +61,16 @@ export class CollectionService {
.delete();
}
getAuthContext() {
getPublicCollectionById(id: Collection['id']) {
return Collection.query()
.where('id', id)
.andWhere('visibility', Visibility.PUBLIC)
.preload('links')
.preload('author')
.firstOrFail();
}
private getAuthContext() {
const context = HttpContext.getOrFail();
if (!context.auth.user || !context.auth.user.id) {
throw new Error('User not authenticated');