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

Refactor Model Architecture #1055

Merged
merged 319 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
319 commits
Select commit Hold shift + click to select a range
2bdfe71
Added new provider for album authorisation
nagmat84 Aug 12, 2021
4cfb3c3
Re-used logic for smart album access from album itself
nagmat84 Aug 13, 2021
c1f9bd5
Removed reverse relation from base class to child class.
nagmat84 Aug 13, 2021
967e07b
Migration renames `viewable` to `requires_link`
nagmat84 Aug 13, 2021
6412bd0
Corrected type of attribute `public` of class `Photo`
nagmat84 Aug 13, 2021
acb6ec9
Complete overhaul of migration due to anoying bugs
nagmat84 Aug 13, 2021
83ce025
Created class FakeModel to work around certain PHP restrictions relat…
nagmat84 Aug 13, 2021
21527f9
Repaired upload check
nagmat84 Aug 13, 2021
630b412
Corrected documentation of method signature
nagmat84 Aug 13, 2021
ebc5af8
Clean up of tests (missing/mismatching documentation, unused paramete…
nagmat84 Aug 13, 2021
262612f
Fixed ForwardToParentImplementation for newly created models.
nagmat84 Aug 13, 2021
b44e296
Fixed a bug.
nagmat84 Aug 13, 2021
59ead43
Updated base and child classes such that attributes goes into the cor…
nagmat84 Aug 13, 2021
0643668
Fixed bug in albums.
nagmat84 Aug 13, 2021
77cb0f1
Corrected HTTP return codes
nagmat84 Aug 14, 2021
e999f52
Fixed ownership update during move
nagmat84 Aug 14, 2021
fe3a102
Added support to eagerly load photos and sub-albums (if applicable) o…
nagmat84 Aug 14, 2021
004e5b2
Fixed authorization if no user is logged in.
nagmat84 Aug 14, 2021
5931220
Fixed eager loading for single models
nagmat84 Aug 14, 2021
c3d3c6b
Fixed returned JSON array.
nagmat84 Aug 14, 2021
411e16e
Added missing method description
nagmat84 Aug 14, 2021
036266d
Fixed validation in album controller
nagmat84 Aug 14, 2021
ace73df
Fixing more tests and silly bugs
nagmat84 Aug 14, 2021
e27a961
Fixed password for unlock, return results of album controller and tests
nagmat84 Aug 14, 2021
59f699c
Fixed deletion of album
nagmat84 Aug 14, 2021
9c305bd
Corrected filter queries for albums (queried properties are actually …
nagmat84 Aug 14, 2021
dad6176
Removed handler for model not found
nagmat84 Aug 14, 2021
21574c4
Fixed return results.
nagmat84 Aug 14, 2021
8a150f0
Fixed referenced table in diagnostics
nagmat84 Aug 15, 2021
a89272d
Clean up of tests
nagmat84 Aug 15, 2021
b81e5c1
Beautification of Photo controller
nagmat84 Aug 15, 2021
fb8eb42
Fixed caching bug
nagmat84 Aug 15, 2021
01cecd2
Cleanup of test
nagmat84 Aug 15, 2021
d799e49
Fixed return type and comment
nagmat84 Aug 15, 2021
2cf1971
Fixed tests
nagmat84 Aug 15, 2021
4da41c0
Fixed installation test
nagmat84 Aug 19, 2021
b78f804
Cleaned up notifications.
nagmat84 Aug 19, 2021
9ca6768
Added rules for IDs
nagmat84 Aug 19, 2021
dff8749
Fixed a lot of tests.
nagmat84 Aug 19, 2021
cb10702
Fixed name of DB column, fixed missing DB columns, fixed test.
nagmat84 Aug 20, 2021
50a4281
Corrected spelling
nagmat84 Aug 21, 2021
43d3e47
Fixed photo test
nagmat84 Aug 21, 2021
dcf8d7d
Fixed test
nagmat84 Aug 21, 2021
7da1b61
Fixed user tests
nagmat84 Aug 22, 2021
343b79a
All tests running again.
nagmat84 Aug 22, 2021
cf75b97
Converted taken_at_min and taken_at_max into a relation.
nagmat84 Sep 6, 2021
31b5780
Revert "Converted taken_at_min and taken_at_max into a relation."
nagmat84 Sep 7, 2021
08c95b1
Added virtual attributes to TagAlbum
nagmat84 Sep 7, 2021
1546ee0
Fixed smart albums
nagmat84 Sep 7, 2021
c434b99
Fixed Albums::getTree
nagmat84 Sep 7, 2021
1ebe85d
Fixed type error for next and previous photo ID.
nagmat84 Sep 7, 2021
9ad9763
Fixed sharing
nagmat84 Sep 7, 2021
f367ec5
Fixed bug concerning owner_id
nagmat84 Sep 7, 2021
b287840
Fixed name of parameters for album sorting
nagmat84 Sep 8, 2021
0d124a8
Fixed photo sorting.
nagmat84 Sep 8, 2021
3d8e366
Fixed boolean for get position data.
nagmat84 Sep 8, 2021
63b44d8
Improved performance of AlbumAuthorisationProvider.
nagmat84 Sep 8, 2021
099c1b4
Improved performance of SQL queries
nagmat84 Sep 8, 2021
5b2550c
Created custom album query.
nagmat84 Sep 10, 2021
a7fad66
Fixed test for position data.
nagmat84 Sep 10, 2021
3fbade5
Removed unnessary trait after global scope of albums become query bui…
nagmat84 Sep 10, 2021
1e8e346
Moved max-taken_at and min_taken_at to correct class.
nagmat84 Sep 10, 2021
2b8e238
Renaming of album related classes
nagmat84 Sep 10, 2021
659dc5b
Created class PhotoAuthorisationProvider and refactored other classes…
nagmat84 Sep 11, 2021
a7a0eca
Moved edit checks into correct classes.
nagmat84 Sep 11, 2021
5ce5207
Moved sorting logic to decorator.
nagmat84 Sep 11, 2021
246c5e9
Renamed attributes
nagmat84 Sep 11, 2021
f86858e
Removed conflicting casts and get mutator
nagmat84 Sep 12, 2021
673086f
Added user agent for downloads initiated by PHP
nagmat84 Sep 12, 2021
286d1ca
Use correct rule for album IDs upon import
nagmat84 Sep 12, 2021
e4a908b
Updated front-end for correct import
nagmat84 Sep 12, 2021
76662e5
Updated front-end
nagmat84 Sep 12, 2021
bb3b401
Fixed password input
nagmat84 Sep 12, 2021
fc62b31
Resolved some todos with respect to photo authorisation.
nagmat84 Sep 12, 2021
f59ad2a
Resolved ToDo for TagAlbum
nagmat84 Sep 12, 2021
811cc3b
Performance improvement for Albums::get
nagmat84 Sep 12, 2021
b98aa94
Added downgrade migration.
nagmat84 Sep 12, 2021
9002ece
Fixed migration.
nagmat84 Sep 12, 2021
03dc262
Fixed migration anew.
nagmat84 Sep 12, 2021
033cea7
Fixed downgrade migration.
nagmat84 Sep 12, 2021
2dc2b31
And another fix. Grmpf.
nagmat84 Sep 12, 2021
cb739d9
I'm tired of PHP and Laravel which use fragile strings everywhere
nagmat84 Sep 12, 2021
9b3dddc
Fixed a strange bug in an old migration.
nagmat84 Sep 12, 2021
23fd02d
Next try.
nagmat84 Sep 12, 2021
50df02b
Why does an old migration suddenly fail?!
nagmat84 Sep 12, 2021
c1585c9
Why do we have NULL values for _lft, _rgt during migration?!
nagmat84 Sep 12, 2021
f973eaf
Fixes.
nagmat84 Sep 12, 2021
3920e41
Fixed imgDirection --> img_direction and default value `description`.
nagmat84 Sep 12, 2021
d395bb7
Changed default for column `tags` due silly constraints on old MySQL …
nagmat84 Sep 12, 2021
7472667
Remove foreign constraint on downgrade
nagmat84 Sep 12, 2021
e5e8f38
Removed more foreign constraints on downgrade.
nagmat84 Sep 12, 2021
5211611
Fixed bugs which do suprisingly not trigger a failed test for SQLite
nagmat84 Sep 13, 2021
abacaee
Created new PhpStorm meta file
nagmat84 Sep 13, 2021
f6f09d6
Fixed Archive::do
nagmat84 Sep 16, 2021
9104e9e
Fixed a strange error on PosgreSQL which resultet into unintended pho…
nagmat84 Sep 16, 2021
fe5adb8
Fixed migration.
nagmat84 Sep 16, 2021
4284ae1
Merge branch 'refactor_photo_model' into refactor_album_model
nagmat84 Sep 16, 2021
e2ece02
Fixed typos discovered by @kamil4.
nagmat84 Oct 10, 2021
b36cb44
Added album query for browseable albums.
nagmat84 Oct 17, 2021
48fbeed
Fixed error in search
nagmat84 Oct 17, 2021
5eb9a13
Fixed search restriction for admin
nagmat84 Oct 17, 2021
cd31df5
Modify the original album query, do not create a new one
nagmat84 Oct 17, 2021
e301d4b
Tentatively fixed incompatible types in API
nagmat84 Oct 17, 2021
9ce1d05
Fixed table reference
nagmat84 Oct 17, 2021
f576a93
Fixed search of unsorted albums for admin user.
nagmat84 Oct 17, 2021
34f3642
Added forgotten commit
nagmat84 Oct 17, 2021
848453b
Reverted visbility filter
nagmat84 Oct 17, 2021
7dc35a7
Fixed logic for maySeeUnsorted as pointed out by @kamil4.
nagmat84 Oct 18, 2021
14c3c65
Aliased inner join table.
nagmat84 Oct 18, 2021
9d82150
Added a JOIN clause to check explicitly if the target album is access…
nagmat84 Oct 18, 2021
6e4c33e
Fixed browsability filter to check accessibility of origin.
nagmat84 Oct 19, 2021
852d2d5
Fixed accidental leakage of thumbnails of password-protected albums.
nagmat84 Oct 19, 2021
ca10795
Fixed bug in migration script
nagmat84 Oct 22, 2021
074e0d6
Replaced ->whereHas with more efficient ->join
nagmat84 Oct 23, 2021
b532a73
Turned thumbnails of real albums into a relation (query is wrong though)
nagmat84 Oct 24, 2021
1eeda54
Fixed query for HasAlbumThumb
nagmat84 Oct 24, 2021
3a9ea54
Renamed column and table aliases to prepare merge with authorisation …
nagmat84 Oct 24, 2021
26b8cf0
Removed unecessary boolean flag.
nagmat84 Oct 24, 2021
cee81b5
PhotoAuthorisationProvider only joins with necessary tables
nagmat84 Oct 24, 2021
b9c235b
Prepared Photo and AlbumAuthorizationProvider for HasAlbumThumb.
nagmat84 Oct 24, 2021
afd3206
HasAlbumThumb uses AlbumAuthorizationProvider
nagmat84 Oct 24, 2021
a26468b
Fixed HasAlbumThumb to only return thumbs of albums which are accessi…
nagmat84 Oct 24, 2021
327a546
Fixed two bugs which are only triggred by the MySQL tests of our CI.
nagmat84 Oct 24, 2021
5b511bc
A lot of fixes due to @kamil4 (mostly typos and spelling errors)
nagmat84 Oct 30, 2021
f16c1e1
Revised architecture which avoids to re-implement parts of a model fo…
nagmat84 Oct 31, 2021
4a98d38
Moved identical methods from TagAlbum and Album to BaseAlbum.
nagmat84 Oct 31, 2021
dfee77e
Removed unnecessary code for album deletion which would only be requi…
nagmat84 Oct 31, 2021
dc72ebf
Added optimization of autoloader to Github workflows
nagmat84 Oct 31, 2021
724f631
Fixed ordering of album thumb.
nagmat84 Nov 1, 2021
d7a5dd6
Migrated to our own fork of NestedSet
nagmat84 Nov 1, 2021
5c1c043
Fixed thumb relation for albums to honor explicitly set covers.
nagmat84 Nov 1, 2021
0f7e8c9
Fixed version of Spatie which cannot honor semantic versioning.
nagmat84 Nov 1, 2021
72cd47c
Synced front-end
nagmat84 Nov 1, 2021
f2ff4b1
Fixes due to comments by @ildyria and @kamil4.
nagmat84 Nov 1, 2021
3b8cd60
Fixed a bug wrt. sorting
nagmat84 Nov 1, 2021
443690f
Fixed the previous fix. :-(
nagmat84 Nov 1, 2021
09da5ce
Merge branch 'master' into refactor_photo_model
nagmat84 Nov 2, 2021
f467055
Moved migration to to end
nagmat84 Nov 2, 2021
93579ed
Merge branch 'refactor_photo_model' into refactor_album_model
nagmat84 Nov 2, 2021
045ec6c
Fixed migration.
nagmat84 Nov 14, 2021
865d24b
Fixed bug with multiple appearing albums and photos.
nagmat84 Nov 14, 2021
f1a86aa
Merge branch 'master' into refactor_photo_model
nagmat84 Nov 20, 2021
7e7f960
Merge branch 'refactor_photo_model' into refactor_album_model
nagmat84 Nov 20, 2021
a4527b8
Corrected comment.
nagmat84 Nov 27, 2021
5849882
Synced front-end
nagmat84 Nov 28, 2021
b83006c
Merge branch 'master' into refactor_photo_model
nagmat84 Nov 28, 2021
1df0c58
Merged migration script for photos and albums into a single migration…
nagmat84 Nov 28, 2021
4c4191b
Removed unnessary `size_variants_raw` and replaced with customized re…
nagmat84 Nov 28, 2021
aca0fd1
Workaround for randomly and strangly failing test on Github workflows.
nagmat84 Nov 29, 2021
ae22cf2
Trivial renaming from `size_variant.size_variant` into `size_variant.…
nagmat84 Nov 29, 2021
0d7a4ae
More consistent return values.
nagmat84 Nov 29, 2021
cce9713
Sync changed front-end
nagmat84 Nov 30, 2021
d4f1882
Removed listener from photo and added code diretly to `delete`
nagmat84 Dec 1, 2021
d3b752d
Removed observer for photo and integrated logic for delete directly i…
nagmat84 Dec 1, 2021
692a303
Removed observer for SizeVariant and added code diretly to `delete.
nagmat84 Dec 1, 2021
a563060
Removed strange "Notifiable" trait from symbolic links.
nagmat84 Dec 1, 2021
a0fa705
Removed observer for symbolic link and moved to code directly into mo…
nagmat84 Dec 1, 2021
cf630b1
Removed observer from HasTimeBasedID
nagmat84 Dec 1, 2021
f129946
Merge branch 'master' into refactor_photo_model
nagmat84 Dec 3, 2021
1c0ec8f
Apply fixes from PHP-CS-Fixer (#1159)
github-actions[bot] Dec 4, 2021
b6ae5d4
Added some syntactic sugar introduced by PHP 8
nagmat84 Dec 4, 2021
2b01ed9
Fixed problem with new version of Spatie
nagmat84 Dec 4, 2021
e63893c
MOved migration to end.
nagmat84 Dec 4, 2021
f9ae4f9
Fixed failing foreign key in migration script.
nagmat84 Dec 5, 2021
889500e
Fixed an old database migration script.
nagmat84 Dec 5, 2021
0ab4460
Fixes timestamps
nagmat84 Dec 5, 2021
6b90631
update codecov.yml (#1158)
ildyria Dec 3, 2021
74c8066
Added random ID as primary key to photos and albums
nagmat84 Dec 5, 2021
ed49c3c
Added some indices after analyzing @ildyria's sample database.
nagmat84 Dec 6, 2021
ea4d673
More fancy indices to speed up Lychee.
nagmat84 Dec 8, 2021
2eeb07c
Fixed another error caused by this stupid Laravel Collections
nagmat84 Dec 8, 2021
5fc241d
Fixed console command to reset admin password.
nagmat84 Dec 8, 2021
ed1fc8d
Merge branch 'master' into refactor_photo_model
nagmat84 Dec 9, 2021
14a76b4
Sorting according to upload/creation time uses column "created_at" no…
nagmat84 Dec 11, 2021
3c4a475
Fixed an overlooked test (why didn't it failed in previous runs?!)
nagmat84 Dec 11, 2021
ef121ff
Fixed some overlooked integer IDs
nagmat84 Dec 12, 2021
28a4955
Fixed another overlooked, broken test
nagmat84 Dec 12, 2021
0cf4dd9
Bring some API aspects forward to avoid another migration.
nagmat84 Dec 15, 2021
34b481b
Removed setting of SQL mode from migration.
nagmat84 Dec 16, 2021
f4b904f
Merge branch 'master' into refactor_photo_model
nagmat84 Dec 16, 2021
1789e7c
Merge branch 'master' into refactor_photo_model
nagmat84 Dec 20, 2021
728394b
Fixed some left overs which still assumed numeric IDs
nagmat84 Dec 21, 2021
70edf7e
Fix the restoring of explicit covers of albums
kamil4 Dec 30, 2021
14db3f7
Added updated front-end.
nagmat84 Dec 31, 2021
dd5c36e
Fixed bug which denied non-admin users with the upload right to creat…
nagmat84 Dec 31, 2021
389275f
Fixed bug such that admin sees thumbnails of albums of other users
nagmat84 Dec 31, 2021
cb6f458
Fixed grouping by owner for shared albums.
nagmat84 Dec 31, 2021
3cf7e3c
Apply suggestions from code review
nagmat84 Dec 31, 2021
8fc73d5
Fixed a bug in the view controller.
nagmat84 Dec 31, 2021
c441013
Added redirection support for legacy IDs.
nagmat84 Dec 31, 2021
1152870
Fixed redirection test and cleanup of redirection code.
nagmat84 Jan 1, 2022
22078e1
Added support for translation of legacy IDs by front-end
nagmat84 Jan 1, 2022
fb2fee1
Synced with @kamil4's recent changes to the front-end
nagmat84 Jan 1, 2022
a48ed6c
Made search results being sorted
nagmat84 Jan 1, 2022
92516d0
Synced @kamil4's changes of the front-end.
nagmat84 Jan 2, 2022
371a1bd
Fixed issue with sorting of public albums wrt. to anonymous users.
nagmat84 Jan 2, 2022
a14fecf
Fixed bug which prevented uploading to root/unsorted.
nagmat84 Jan 2, 2022
f5cbf4e
Fixed bug which leaked unsorted photos.
nagmat84 Jan 2, 2022
f60a708
Upgrade to timestamps with microsecond resolution.
nagmat84 Jan 2, 2022
2bcec44
Workaround for a silly Laravel bug in the migration.
nagmat84 Jan 3, 2022
0068b50
Added id/time-conversion and made migration fancy
nagmat84 Jan 3, 2022
8c8129d
Set creation time of photos after upload not after processing.
nagmat84 Jan 3, 2022
ace7fa9
Fixed tests due to more accurate timestamps
nagmat84 Jan 3, 2022
38a086c
Allow null albumID for setAlbum and duplicate
kamil4 Jan 3, 2022
48e1886
fix timestamps for page_content
ildyria Jan 3, 2022
ff0bdbf
Fixed copy-to for root album.
nagmat84 Jan 3, 2022
4c6dc31
Fixed foreign constraint when a cover photo is deleted.
nagmat84 Jan 3, 2022
44384bf
Allow unprivilege users to unset album covers (i.e. use the `null` ph…
nagmat84 Jan 3, 2022
b55a9d1
Made migration a little bit more robust wrt. to a former Lychee bug
nagmat84 Jan 3, 2022
3784b71
Fixed test case for photo duplication.
nagmat84 Jan 3, 2022
5290adb
Allow uploading to the Recent smart album
kamil4 Jan 3, 2022
3b5dc1c
Clean up the mess left by the front end
kamil4 Jan 3, 2022
4e9b569
Support null albumID
kamil4 Jan 4, 2022
c50b2d6
Fixed missing sorting in case album uses default sorting.
nagmat84 Jan 4, 2022
082b688
Revert "Clean up the mess left by the front end"
nagmat84 Jan 4, 2022
de773d7
Synced front-end
nagmat84 Jan 4, 2022
904d4d2
Support to translate all legacy model IDs in a single request.
nagmat84 Jan 4, 2022
01960b2
Sync with front-end
nagmat84 Jan 4, 2022
cdf3a81
Only use SORT_NATURAL on string columns
kamil4 Jan 4, 2022
af9cb7c
Don't serialize owner_id
kamil4 Jan 5, 2022
3a269fd
Support serializing default sorting and hiding it
kamil4 Jan 5, 2022
c0502ed
Fix findWhereIDsIn for smart albums
kamil4 Jan 5, 2022
a6111e1
Restore checking downloadable flag of parent album
kamil4 Jan 5, 2022
3418285
Don't serialize owner_id of photos either
kamil4 Jan 5, 2022
eb083bd
Fix the serialization of sorting info
kamil4 Jan 5, 2022
be1035d
Turn empty album description into null
kamil4 Jan 5, 2022
e211b10
Use the same sorting as Top
kamil4 Jan 5, 2022
33eeff5
Fix #1187
kamil4 Jan 5, 2022
60b1706
Synced front-end
nagmat84 Jan 6, 2022
43d4070
Removed unnessary Laravel mutators for sortigng
nagmat84 Jan 6, 2022
572de1e
Fixed some type cast warnings
nagmat84 Jan 6, 2022
17f1de7
Fixed wrong configuration option in `getEffictiveSorting[Column|Order]`
nagmat84 Jan 6, 2022
d4172e3
Fix a crash with skip_duplicates enabled
kamil4 Jan 6, 2022
3335fcc
Made album deletion mor robust.
nagmat84 Jan 6, 2022
175430d
Fixed album deletion bug.
nagmat84 Jan 6, 2022
934930a
Fixed a bug wrt. to skip duplicates.
nagmat84 Dec 30, 2021
69a8086
Fix skip_duplicates for import from server
kamil4 Jan 6, 2022
1c33efc
Fix ownership for album moves and merges
kamil4 Jan 6, 2022
9b92a7a
Fixed a bug when creating the tree of albums.
nagmat84 Jan 7, 2022
4459a25
Fixed move-to and merge operations.
nagmat84 Jan 7, 2022
90858e6
Save updates after auto-rotation
kamil4 Jan 8, 2022
9667255
Reset file permissions on the original file
kamil4 Jan 8, 2022
d8e0eb3
Added a missing `save` after adding a Google Motion Picture
nagmat84 Jan 8, 2022
45d2927
Fix deleting Unsorted for non-admins
kamil4 Jan 9, 2022
f918158
Reverted accidental change of checksum upon rotation + sync of front-end
nagmat84 Jan 9, 2022
f347990
Migrate ISO values
kamil4 Jan 10, 2022
0011ce0
Fixed visibility of albums in tree.
nagmat84 Jan 10, 2022
68b2d2f
Improved/extended checksum handling.
nagmat84 Jan 10, 2022
f9563ec
Enable redirection by default + sync of front-end.
nagmat84 Jan 13, 2022
ed17b7e
DB version increased.
nagmat84 Jan 13, 2022
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
62 changes: 32 additions & 30 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
<?php

$finder = array_reduce(
[
__DIR__ . '/app/',
__DIR__ . '/database/',
__DIR__ . '/resources/',
__DIR__ . '/routes/',
__DIR__ . '/tests/',
],
function (PhpCsFixer\Finder $finder, $dir) {
return $finder->in($dir);
},
PhpCsFixer\Finder::create()->ignoreUnreadableDirs()
[
__DIR__ . '/app/',
__DIR__ . '/database/',
__DIR__ . '/resources/',
__DIR__ . '/routes/',
__DIR__ . '/tests/',
],
function (PhpCsFixer\Finder $finder, $dir) {
return $finder->in($dir);
},
PhpCsFixer\Finder::create()->ignoreUnreadableDirs()
)->notName('*.blade.php');
$rules = [
'@Symfony' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'backtick_to_shell_exec' => true,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'multiline_comment_opening_closing' => true,
'no_php4_constructor' => true,
'phpdoc_no_empty_return' => false,
'single_blank_line_at_eof' => false,
'yoda_style' => false,
'concat_space' => ['spacing' => 'one'],
'no_superfluous_phpdoc_tags' => false,
'@Symfony' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'backtick_to_shell_exec' => true,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'multiline_comment_opening_closing' => true,
'no_php4_constructor' => true,
'phpdoc_no_empty_return' => false,
'single_blank_line_at_eof' => false,
'yoda_style' => false,
'concat_space' => ['spacing' => 'one'],
'no_superfluous_phpdoc_tags' => false,
];
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules($rules)
->setIndent("\t")
->setLineEnding("\n")
->setFinder($finder);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules($rules)
->setIndent("\t")
->setLineEnding("\n")
->setFinder($finder);
13 changes: 6 additions & 7 deletions app/Actions/Album/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use App\Models\Configs;
use App\Models\Logs;
use App\Models\Photo;
use Illuminate\Support\Facades\Storage;
use App\Models\SizeVariant;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\HttpFoundation\StreamedResponse;
use ZipStream\ZipStream;
Expand Down Expand Up @@ -155,16 +155,15 @@ private function compress_album($photos_sql, $dir_name, &$dirs, $parent_dir, $al

$is_raw = ($photo->type == 'raw');

$prefix_url = $is_raw ? 'raw/' : 'big/';
$url = Storage::path($prefix_url . $photo->url);
$fullPath = $photo->size_variants->getSizeVariant(SizeVariant::ORIGINAL)->full_path;
// Check if readable
if (!@is_readable($url)) {
Logs::error(__METHOD__, __LINE__, 'Original photo missing: ' . $url);
if (!@is_readable($fullPath)) {
Logs::error(__METHOD__, __LINE__, 'Original photo missing: ' . $fullPath);
continue;
}

// Get extension of image
$extension = Helpers::getExtension($url, false);
$extension = Helpers::getExtension($fullPath, false);

// Set title for photo
$title = str_replace($this->badChars, '', $photo->title);
Expand Down Expand Up @@ -198,7 +197,7 @@ private function compress_album($photos_sql, $dir_name, &$dirs, $parent_dir, $al
set_time_limit(ini_get('max_execution_time'));

// add a file named 'some_image.jpg' from a local file 'path/to/image.jpg'
$zip->addFileFromPath($dir_name . '/' . $file, $url);
$zip->addFileFromPath($dir_name . '/' . $file, $fullPath);
} // foreach ($photos)

// Recursively compress subalbums
Expand Down
8 changes: 4 additions & 4 deletions app/Actions/Album/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

namespace App\Actions\Album;

use App\Actions\Album\Extensions\StoreAlbum;
use App\Facades\AccessControl;
use App\Models\Album;

class Create extends Action
{
use StoreAlbum;

/**
* @param string $albumID
*
Expand All @@ -20,8 +17,11 @@ public function create(string $title, int $parent_id): Album
$album = $this->albumFactory->makeFromTitle($title);

$this->set_parent($album, $parent_id);
if (!$album->save()) {
throw new \RuntimeException('could not persist album to DB');
}

return $this->store_album($album);
return $album;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions app/Actions/Album/CreateTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@

namespace App\Actions\Album;

use App\Actions\Album\Extensions\StoreAlbum;
use App\Facades\AccessControl;
use App\Models\Album;

class CreateTag extends Action
{
use StoreAlbum;

/**
* Create a new smart album based on tags.
*
* @param string $title
* @param string $show_tags
*
* @return Album|Response
* @return Album
*/
public function create(string $title, string $show_tags): Album
{
Expand All @@ -27,7 +24,10 @@ public function create(string $title, string $show_tags): Album

$album->smart = true;
$album->showtags = $show_tags;
if (!$album->save()) {
throw new \RuntimeException('could not persist album to DB');
}

return $this->store_album($album);
return $album;
}
}
13 changes: 9 additions & 4 deletions app/Actions/Album/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ public function do(string $albumIDs): bool
$no_error = true;
// root = unsorted
if ($albumIDs == 'unsorted') {
$photos = Photo::OwnedBy(AccessControl::id())->where('album_id', '=', null)->get();
$photos = Photo::OwnedBy(AccessControl::id())
->with(['size_variants_raw', 'size_variants_raw.sym_links'])
->where('album_id', '=', null)
->get();

/** @var Photo $photo */
foreach ($photos as $photo) {
$no_error &= $photo->predelete();
$no_error &= $photo->delete();
}

Expand All @@ -31,7 +34,9 @@ public function do(string $albumIDs): bool

$albums = Album::whereIn('id', explode(',', $albumIDs))->get();

$sqlPhoto = Photo::leftJoin('albums', 'photos.album_id', '=', 'albums.id')
$sqlPhoto = Photo::query()
->with(['size_variants_raw', 'size_variants_raw.sym_links'])
->leftJoin('albums', 'photos.album_id', '=', 'albums.id')
->select('photos.*');

foreach ($albums as $album) {
Expand All @@ -40,8 +45,8 @@ public function do(string $albumIDs): bool
}

$photos = $sqlPhoto->get();
/** @var Photo $photo */
foreach ($photos as $photo) {
$no_error &= $photo->predelete();
$no_error &= $photo->delete();
}

Expand Down
17 changes: 4 additions & 13 deletions app/Actions/Album/Extensions/LocationData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Actions\Album\Extensions;

use App\ModelFunctions\SymLinkFunctions;
use App\Models\Photo;
use Illuminate\Database\Eloquent\Builder;

trait LocationData
Expand All @@ -17,26 +17,17 @@ trait LocationData
*/
public function photosLocationData(Builder $photos_sql)
{
$symLinkFunctions = resolve(SymLinkFunctions::class);

$return_photos = [];
$photo_counter = 0;
$photos = $photos_sql
->whereNotNull('latitude')
->whereNotNull('longitude')
->with('album')
->with(['album', 'size_variants_raw', 'size_variants_raw.sym_links'])
->get();

/*
* @var Photo
*/
/** @var Photo $photo_model */
foreach ($photos as $photo_model) {
$photo = $photo_model->toReturnArray();
$symLinkFunctions->getUrl($photo_model, $photo);

// Add to return
$return_photos[$photo_counter] = $photo;

$return_photos[$photo_counter] = $photo_model->toArray();
$photo_counter++;
}

Expand Down
46 changes: 0 additions & 46 deletions app/Actions/Album/Extensions/StoreAlbum.php

This file was deleted.

21 changes: 2 additions & 19 deletions app/Actions/Album/Photos.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@

namespace App\Actions\Album;

use App\Facades\AccessControl;
use App\ModelFunctions\SymLinkFunctions;
use App\Models\Album;
use App\Models\Configs;
use App\Models\Photo;
use Illuminate\Database\Eloquent\Collection;

class Photos
{
/** @var SymLinkFunctions */
private $symLinkFunctions;

public function __construct(SymLinkFunctions $symLinkFunctions)
{
$this->symLinkFunctions = $symLinkFunctions;
}

/**
* take a $photo_sql query and return an array containing their pictures.
*
Expand All @@ -29,7 +18,7 @@ public function __construct(SymLinkFunctions $symLinkFunctions)
public function get(Album $album): array
{
[$sortingCol, $sortingOrder] = $album->get_sort();
$photos_sql = $album->get_photos();
$photos_sql = $album->get_photos()->with(['size_variants_raw', 'size_variants_raw.sym_links']);

$previousPhotoID = '';
$return_photos = [];
Expand Down Expand Up @@ -66,13 +55,7 @@ public function get(Album $album): array
/** @var Photo $photo_model */
foreach ($photos as $photo_model) {
// Turn data from the database into a front-end friendly format
$photo = $photo_model->toReturnArray();
$photo['license'] = $photo_model->get_license($album->get_license());
ildyria marked this conversation as resolved.
Show resolved Hide resolved

$this->symLinkFunctions->getUrl($photo_model, $photo);
if (!AccessControl::is_current_user($photo_model->owner_id) && !$album->is_full_photo_visible()) {
$photo_model->downgrade($photo);
}
$photo = $photo_model->toArray();

// Set previous and next photoID for navigation purposes
$photo['previousPhoto'] = $previousPhotoID;
Expand Down
27 changes: 22 additions & 5 deletions app/Actions/Import/Exec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace App\Actions\Import;

use App\Actions\Album\Create;
use App\Actions\Import\Extensions\ImportPhoto;
use App\Actions\Album\Create as AlbumCreate;
use App\Actions\Photo\Create as PhotoCreate;
use App\Actions\Photo\Extensions\Constants;
use App\Actions\Photo\Extensions\SourceFileInfo;
use App\Actions\Photo\Strategies\ImportMode;
use App\Exceptions\PhotoResyncedException;
use App\Exceptions\PhotoSkippedException;
use App\Facades\Helpers;
Expand All @@ -17,9 +19,9 @@

class Exec
{
use ImportPhoto;
use Constants;

// TODO: Refactor this and use `ImportMode` instead of four boolean properties
public $skip_duplicates = false;
public $resync_metadata = false;
public $delete_imported;
Expand Down Expand Up @@ -243,7 +245,22 @@ public function do(
if (@exif_imagetype($file) !== false || in_array(strtolower($extension), $this->validExtensions, true) || $is_raw) {
// Photo or Video
try {
if ($this->photo($file, $this->delete_imported, $this->import_via_symlink, $albumID, $this->skip_duplicates, $this->resync_metadata) === false) {
// TODO: Refactor this, rationale see below
// This is not the way how `PhotoCreate` is supposed
// to be used.
// Actually, an instance of the class should only
// be created once using a single instance of
// `ImportMode` and then `PhotoCreate::add` should
// be called for each file.
$photoCreate = new PhotoCreate(new ImportMode(
$this->delete_imported,
$this->import_via_symlink,
$this->skip_duplicates,
$this->resync_metadata
));
if (
$photoCreate->add(SourceFileInfo::createForLocalFile($file), $albumID) == null
) {
$this->status_error($file, 'Could not import file');
Logs::error(__METHOD__, __LINE__, 'Could not import file (' . $file . ')');
}
Expand Down Expand Up @@ -273,7 +290,7 @@ public function do(
->first();
}
if ($album === null) {
$create = resolve(Create::class);
$create = resolve(AlbumCreate::class);
$album = $create->create(basename($dir), $albumID);
// this actually should not fail.
if ($album === false) {
Expand Down
Loading