Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove is_public & deprecated Public smart album #2221

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/Actions/Album/SetProtectionPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,5 @@ public function do(BaseAlbum $album, AlbumProtectionPolicy $protectionPolicy, bo
}
$active_permissions->base_album_id = $album->id;
$active_permissions->save();

// Reset permissions for photos
$album->photos()->update(['photos.is_public' => false]);
}
}
5 changes: 1 addition & 4 deletions app/Actions/Photo/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use App\Models\Album;
use App\Models\Photo;
use App\SmartAlbums\BaseSmartAlbum;
use App\SmartAlbums\PublicAlbum;
use App\SmartAlbums\StarredAlbum;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use function Safe\filemtime;
Expand Down Expand Up @@ -214,9 +213,7 @@ protected function initParentAlbum(?AbstractAlbum $album = null): void
$this->strategyParameters->album = $album;
} elseif ($album instanceof BaseSmartAlbum) {
$this->strategyParameters->album = null;
if ($album instanceof PublicAlbum) {
$this->strategyParameters->is_public = true;
} elseif ($album instanceof StarredAlbum) {
if ($album instanceof StarredAlbum) {
$this->strategyParameters->is_starred = true;
}
} else {
Expand Down
1 change: 0 additions & 1 deletion app/Actions/Photo/Strategies/AddDuplicateStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function do(): Photo
$existing = $this->photo;
$this->photo = $existing->replicate();
// Adopt settings of duplicated photo acc. to target album
$this->photo->is_public = $this->parameters->is_public;
$this->photo->is_starred = $this->parameters->is_starred;
$this->setParentAndOwnership();
$this->photo->save();
Expand Down
1 change: 0 additions & 1 deletion app/Actions/Photo/Strategies/AddStandaloneStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public function do(): Photo
{
// Create and save "bare" photo object without size variants
$this->hydrateMetadata();
$this->photo->is_public = $this->parameters->is_public;
$this->photo->is_starred = $this->parameters->is_starred;
$this->setParentAndOwnership();

Expand Down
3 changes: 0 additions & 3 deletions app/Actions/Photo/Strategies/AddStrategyParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ class AddStrategyParameters
/** @var Album|null the intended parent album */
public ?Album $album = null;

/** @var bool indicates whether the new photo shall be public */
public bool $is_public = false;

/** @var bool indicates whether the new photo shall be starred */
public bool $is_starred = false;

Expand Down
2 changes: 0 additions & 2 deletions app/Enum/ColumnSortingPhotoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ enum ColumnSortingPhotoType: string
case CREATED_AT = 'created_at';
case TITLE = 'title';
case DESCRIPTION = 'description';
case IS_PUBLIC = 'is_public';

case TAKEN_AT = 'taken_at';
case IS_STARRED = 'is_starred';
Expand Down Expand Up @@ -46,7 +45,6 @@ public static function localized(): array
self::TAKEN_AT->value => __('lychee.SORT_PHOTO_SELECT_2'),
self::TITLE->value => __('lychee.SORT_PHOTO_SELECT_3'),
self::DESCRIPTION->value => __('lychee.SORT_PHOTO_SELECT_4'),
self::IS_PUBLIC->value => __('lychee.SORT_PHOTO_SELECT_5'),
self::IS_STARRED->value => __('lychee.SORT_PHOTO_SELECT_6'),
self::TYPE->value => __('lychee.SORT_PHOTO_SELECT_7'),
];
Expand Down
1 change: 0 additions & 1 deletion app/Enum/ColumnSortingType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ enum ColumnSortingType: string
case CREATED_AT = 'created_at';
case TITLE = 'title';
case DESCRIPTION = 'description';
case IS_PUBLIC = 'is_public';

// from albums
case MIN_TAKEN_AT = 'min_taken_at';
Expand Down
1 change: 0 additions & 1 deletion app/Enum/SmartAlbumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ enum SmartAlbumType: string
use DecorateBackedEnum;

case UNSORTED = 'unsorted';
case PUBLIC = 'public';
case STARRED = 'starred';
case RECENT = 'recent';
case ON_THIS_DAY = 'on_this_day';
Expand Down
2 changes: 0 additions & 2 deletions app/Factories/AlbumFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use App\Models\TagAlbum;
use App\SmartAlbums\BaseSmartAlbum;
use App\SmartAlbums\OnThisDayAlbum;
use App\SmartAlbums\PublicAlbum;
use App\SmartAlbums\RecentAlbum;
use App\SmartAlbums\StarredAlbum;
use App\SmartAlbums\UnsortedAlbum;
Expand All @@ -24,7 +23,6 @@ class AlbumFactory
public const BUILTIN_SMARTS_CLASS = [
SmartAlbumType::UNSORTED->value => UnsortedAlbum::class,
SmartAlbumType::STARRED->value => StarredAlbum::class,
SmartAlbumType::PUBLIC->value => PublicAlbum::class,
SmartAlbumType::RECENT->value => RecentAlbum::class,
SmartAlbumType::ON_THIS_DAY->value => OnThisDayAlbum::class,
];
Expand Down
21 changes: 0 additions & 21 deletions app/Http/Controllers/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use App\Http\Requests\Photo\MovePhotosRequest;
use App\Http\Requests\Photo\SetPhotoDescriptionRequest;
use App\Http\Requests\Photo\SetPhotoLicenseRequest;
use App\Http\Requests\Photo\SetPhotoPublicRequest;
use App\Http\Requests\Photo\SetPhotosStarredRequest;
use App\Http\Requests\Photo\SetPhotosTagsRequest;
use App\Http\Requests\Photo\SetPhotosTitleRequest;
Expand Down Expand Up @@ -202,26 +201,6 @@ public function setDescription(SetPhotoDescriptionRequest $request): void
$request->photo()->save();
}

/**
* Sets the `is_public` attribute of the given photo.
*
* We do not advise the use of this and would rather see people use albums
* visibility.
* This would highly simplify the code if we remove this.
* Do we really want to keep it ?
*
* @param SetPhotoPublicRequest $request
*
* @return void
*
* @throws LycheeException
*/
public function setPublic(SetPhotoPublicRequest $request): void
{
$request->photo()->is_public = $request->isPublic();
$request->photo()->save();
}

/**
* Set the tags of a photo.
*
Expand Down
46 changes: 0 additions & 46 deletions app/Http/Requests/Photo/SetPhotoPublicRequest.php

This file was deleted.

1 change: 0 additions & 1 deletion app/Http/Resources/Models/PhotoResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public function toArray($request)
'description' => $this->resource->description,
'focal' => $this->resource->focal,
'img_direction' => null,
'is_public' => $this->resource->is_public, // TO BE REMOVED LATER
'is_starred' => $this->resource->is_starred,
'iso' => $this->resource->iso,
'latitude' => $this->resource->latitude,
Expand Down
26 changes: 0 additions & 26 deletions app/Http/RuleSets/Photo/SetPhotoPublicRuleSet.php

This file was deleted.

2 changes: 0 additions & 2 deletions app/Livewire/Components/Pages/Gallery/Albums.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Actions\Albums\Top;
use App\Contracts\Livewire\Reloadable;
use App\Contracts\Models\AbstractAlbum;
use App\Enum\SmartAlbumType;
use App\Factories\AlbumFactory;
use App\Http\Resources\Collections\TopAlbumsResource;
use App\Livewire\DTO\AlbumRights;
Expand Down Expand Up @@ -85,7 +84,6 @@ public function getSmartAlbumsProperty(): Collection
{
return $this->topAlbums->smart_albums
// We filter out the public one (we don't remove it completely to not break the other front-end).
->filter(fn (AbstractAlbum $e, $k) => $e->id !== SmartAlbumType::PUBLIC->value)
->concat($this->topAlbums->tag_albums)
->reject(fn ($album) => $album === null);
}
Expand Down
1 change: 0 additions & 1 deletion app/Models/Builders/AlbumBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ private function applyVisibilityConditioOnPhotos(Builder $countQuery, AlbumQuery
->orWhere('base_albums.owner_id', '=', $userID)
->orWhere('p.owner_id', '=', $userID)
);
$query2->orWhere('p.is_public', '=', true);
};

return $countQuery->where($visibilitySubQuery);
Expand Down
3 changes: 0 additions & 3 deletions app/Models/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
* @property string $title
* @property string|null $description
* @property string[] $tags
* @property bool $is_public
* @property int $owner_id
* @property string|null $type
* @property string|null $iso
Expand Down Expand Up @@ -94,7 +93,6 @@
* @method static PhotoBuilder|Photo whereId($value)
* @method static PhotoBuilder|Photo whereImgDirection($value)
* @method static PhotoBuilder|Photo whereIn(string $column, string $values, string $boolean = 'and', string $not = false)
* @method static PhotoBuilder|Photo whereIsPublic($value)
* @method static PhotoBuilder|Photo whereIsStarred($value)
* @method static PhotoBuilder|Photo whereIso($value)
* @method static PhotoBuilder|Photo whereLatitude($value)
Expand Down Expand Up @@ -152,7 +150,6 @@ class Photo extends Model
'live_photo_url' => MustNotSetCast::class . ':live_photo_short_path',
'owner_id' => 'integer',
'is_starred' => 'boolean',
'is_public' => 'boolean',
'tags' => ArrayCast::class,
'latitude' => 'float',
'longitude' => 'float',
Expand Down
5 changes: 0 additions & 5 deletions app/Policies/PhotoPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ public function canSee(?User $user, Photo $photo): bool
return true;
}

// TODO: to be removed once migrated to v5.
if ($photo->is_public) {
return true;
}

return $photo->album !== null && $this->albumPolicy->canAccess($user, $photo->album);
}

Expand Down
1 change: 0 additions & 1 deletion app/Policies/PhotoQueryPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function applyVisibilityFilter(FixedQueryBuilder $query): FixedQueryBuild
// "OR"-clause.
$visibilitySubQuery = function (FixedQueryBuilder $query2) use ($userId) {
$this->albumQueryPolicy->appendAccessibilityConditions($query2->getQuery());
$query2->orWhere('photos.is_public', '=', true);
if ($userId !== null) {
$query2->orWhere('photos.owner_id', '=', $userId);
}
Expand Down
57 changes: 0 additions & 57 deletions app/SmartAlbums/PublicAlbum.php

This file was deleted.

1 change: 0 additions & 1 deletion database/factories/PhotoFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function definition(): array
'title' => 'CR_' . fake()->numerify('####'),
'description' => null,
'tags' => '',
'is_public' => false,
'owner_id' => 1,
'type' => 'image/jpeg',
'iso' => '100',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class() extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('configs')->where('key', '=', 'sorting_photos_col')->where('value', '=', 'is_public')->update(['value' => 'taken_at']);
DB::table('configs')->where('key', '=', 'sorting_photos_col')->update(['type_range' => 'created_at|taken_at|title|description|is_starred|type']);
}

/**
* Reverse the migrations.
*/
public function down(): void
{
DB::table('configs')->where('key', '=', 'sorting_photos_col')->update(['type_range' => 'created_at|taken_at|title|description|is_public|is_starred|type']);
}
};
Loading
Loading