Commit Graph
374 Commits
Author SHA1 Message Date
REDCODE c77096b0f9 refactor: project PersonPreviewDto directly in repository instead of [NotMapped] entity property
Replace the TempData-like TotalVisibleAlbums [NotMapped] property on
Person with a direct DTO projection in PersonRepository.SearchQuery.
The repository now returns IEnumerable<PersonPreviewDto>, computing
the visibility-aware album count in the EF Core subquery and projecting
only the needed columns. This avoids polluting the entity model with a
context-dependent property.
2026-07-12 17:18:17 +02:00
REDCODE e333d0e9db fix: filter album count by user visibility in person search
- Add Person.TotalVisibleAlbums [NotMapped] populated by repository
- Use visibility-aware album count in PersonMapper
- Restructure PersonRepository.SearchQuery with two-step pagination
  for correct ordering and per-user album visibility filtering
2026-07-12 16:51:29 +02:00
REDCODE ee3511c09a fix: paginate PersonRepository.SearchQuery by ID before loading albums
Include + Skip/Take on a collection navigation can produce duplicate people when sorted by album count, because pagination operates on joined rows. Fix by selecting paged IDs first, then loading the full entities with Include for those IDs.
2026-07-11 20:47:44 +02:00
REDCODE 41c262d157 fix: restore Include(p => p.Albums) in PersonRepository queries
The visibility subquery doesn't load the Albums navigation, so TotalAlbums in the mapper was always 0. Added back a lightweight Include(p => p.Albums) (without Assets/SharedWith chain) to both SearchQuery and GetAllVisible.
2026-07-11 20:39:14 +02:00
REDCODE 837491fa4a fix: guard ILIKE filter in AlbumRepository.SearchQuery against null/empty query 2026-07-11 20:36:33 +02:00
REDCODE 5a2f61d261 perf: push visibility filter into SQL for PersonRepository queries
Replace client-side visibility filtering with EF Core Any() subqueries in SearchQuery and GetAllVisible. This eliminates the cartesian product from the Include chain (Person -> Albums -> Assets -> SharedWith) and lets the database short-circuit the auth check with indexes. Adds null-forgiving operators (!) on navigation access in the query predicates.
2026-07-11 20:35:56 +02:00
REDCODE 851cdfa924 test: restructure WepApiTest.http with three clearly separated users
The test file now creates three distinct users at the start:
  - admin (seeded, admin/admin)
  - curator (created by admin, accessLevel=1)
  - user (registered via /api/auth/register, accessLevel=0)

Each user has its own token variable (admin_token, curator_token,
user_token) and ID variable (admin_id, curator_id, user_id).

Sections are organized: Setup → Auth → User CRUD → Person →
Album → Tag → Asset → Stats → Settings → Cleanup.

All endpoints are tested at each appropriate authorization level:
admin (full access), curator (elevated access), user (own data only),
and anonymous (public data only).
2026-07-11 19:02:58 +02:00
REDCODE 8dd5e7158f test: fix curator user access level from Admin (2) to Curator (1)
EAccessLevel enum: User=0, Curator=1, Admin=2. The test created the
curator user with accessLevel=2 (Admin), making curator_token an
admin token, which broke the 'Create user as curator should 403' test.
2026-07-11 19:00:53 +02:00
REDCODE 9e52cc2351 fix: use zero-based page numbers in AssetController to match API convention
AssetController.GetAll validated page >= 1 (one-based), inconsistent
with PersonController and AlbumController which use zero-based pages.
Adjust validation to page >= 0 and pass page + 1 to the repository
which internally uses one-based.
2026-07-11 18:55:15 +02:00
REDCODE ca8119f356 fix: add [FromQuery] to TagController.GetAll parameter
Complex type PagedSearchParametersDto needs [FromQuery] for GET
requests, otherwise ASP.NET Core tries body binding and returns 415.
2026-07-11 18:54:05 +02:00
REDCODE bef29f5b22 test: add user id to profile update request body
UserUpdateDto.Id is required. The test was sending only username,
causing 400 Bad Request from model binding failure.
2026-07-11 18:52:54 +02:00
REDCODE e27d63cf32 fix: restrict user list to admin only
UserController.GetAll was missing [Authorize(Roles = Admin)],
allowing any authenticated user to list all users.
2026-07-11 18:51:26 +02:00
REDCODE fd46faec21 test: set personId from admin search to ensure it's always populated
Rng user may see no public people, leaving personId unset. Admin
sees all people including test-created ones, so setting personId from
the admin response ensures downstream tests have a valid reference.
2026-07-11 18:50:17 +02:00
REDCODE 648531fcc4 test: handle empty person search results gracefully
The person search may return an empty array when the database has no
publicly visible people. Only set personId when results exist.
2026-07-11 18:48:50 +02:00
REDCODE dda062d959 fix: materialize person search query before client-side visibility filter
The nested Any() through SharedWith navigation cannot be translated
to SQL by EF Core. Apply the same pattern as GetAllVisible and
AlbumController.Search: materialize server-side (search, sort,
pagination), then filter by visibility in memory.
2026-07-11 18:46:10 +02:00
REDCODE 02c62d0dd8 test: add anonymous search tests for persons and albums 2026-07-11 18:42:13 +02:00
REDCODE 2249e0fb2e fix: allow anonymous search for persons and albums
GET /api/person and GET /api/album should not require authentication.
Anonymous users are treated as EAccessLevel.User, so they only see
publicly shared content. PersonController.GetAll uses uid ?? default
instead of uid!.Value to handle null uid safely.
2026-07-11 18:42:10 +02:00
REDCODE f626228c2f fix: return 401 Unauthorized when user data is null in PersonController
PersonController.GetAll used uid!.Value which throws NRE if
authService.GetUserData returns null (e.g. claims present but
user not found). Return 401 Unauthorized instead of crashing.
2026-07-11 18:39:52 +02:00
REDCODE b9fd5e172c test: add endpoint tests for refresh token, albums, curator auth levels
Add HTTP endpoint tests covering:
- Refresh token endpoint (empty body, valid, auth failures)
- Album GET by ID (rng user, admin, non-existent)
- Album search (rng user, admin)
- User get all and profile update (rng user, admin)
- Stats endpoint (admin, curator, rng user 403)
- Tag search and create (admin, rng user 403)
- Asset search (rng user, anonymous)
- Curator-level CRUD permissions (person, album, stats succeed;
  user creation and settings access 403)
- Cleanup of curator test user
2026-07-11 18:33:51 +02:00
REDCODE faa8e93d55 fix: use case-insensitive ILike search for persons and albums
Replace EF Core Contains() with EF.Functions.ILike() which
translates to PostgreSQL ILIKE for case-insensitive matching.
Searching 'alice', 'Alice', or 'ALICE' now returns the same results.
2026-07-11 18:03:17 +02:00
REDCODE 4cffc9b424 feat(api): paginate PersonController.GetAll with sort/search params
Accept PersonSearchParametersDto, forward sort/search/pagination to repository.
Returns paginated results instead of loading all people into memory.
2026-07-11 16:56:54 +02:00
REDCODE 4ea0afe9f6 feat(api): add SearchQuery to PersonRepository with sort/search/pagination
SQL-level search by name, sorting (name, created, albums), and pagination.
Access-level filtering for regular users pushed to SQL via subquery.
Replaces the in-memory GetAllVisible pattern.
2026-07-11 16:56:54 +02:00
REDCODE 334451238b feat(api): pass sort and filter params through AlbumController.Search
Forward SortBy, SortAsc, and Unassigned from AlbumSearchParametersDto to repository.
Remove in-memory unassigned filter (now handled in SQL).
2026-07-11 13:11:12 +02:00
REDCODE 48ebbebee1 feat(api): add sorting and unassigned filter to AlbumRepository.SearchQuery
Extend SearchQuery with sortBy, sortAsc, and unassigned parameters.
Sorting applied via switch expression: name, created, updated, assets, person.
Unassigned filter pushed to SQL instead of in-memory.
2026-07-11 13:11:07 +02:00
REDCODE 31d917c56e fix: remove soft-delete from Person model
Person had a DeletedAt property and all queries filtered by it, but the
controller was hard-deleting via context.People.Remove(). This removes
the DeletedAt property, drops the column via migration, and cleans up
all stale DeletedAt filters in queries.
2026-07-10 18:49:59 +02:00
REDCODE 89c91b2291 refactor: replace tuple + custom header with ChildrenResponse DTO
- Add ChildrenResponse DTO (Children + Since) in Butter.Dtos.Jobs
- JobManager.GetChildren returns List<JobStatusDto> only (no tuple),
  active children filtered via LINQ over activeJobs.Values
- JobsController generates Since timestamp, returns ChildrenResponse
  instead of setting x-delta-timestamp header
- JobsService deserializes ChildrenResponse instead of parsing headers
2026-07-10 17:40:28 +02:00
REDCODE 4a6bc2f8aa Merge branch 'develop' into fix/preview-subjob-status-reporting 2026-07-10 17:37:34 +02:00
REDCODE ac5b75c0d6 fix: suppress nullable warnings on Include chain in GetAllVisible 2026-07-10 17:36:52 +02:00
REDCODE 7e1a2a7ed6 Merge branch 'develop' into fix/preview-subjob-status-reporting 2026-07-10 15:36:11 +00:00
REDCODE e98aa6167e fix: translate GetAllVisible to client-side eval for SharedWith navigation
EF Core cannot translate three-level nested Any through many-to-many
navigation (Person→Albums→Assets→SharedWith). Load data with Include
chain and filter visible persons in-memory instead.
2026-07-10 17:28:13 +02:00
REDCODE 17ddd1c332 feat: hide cosplayers with no visible content from regular users
- IPersonRepository.GetAllVisible filters persons by asset visibility
- For User level: only returns persons that have at least one album
  with a non-deleted asset that is publicly shared, owned by the user,
  or explicitly shared with the user
- For Admin/Curator: returns all persons (unchanged behavior)
- PersonController.GetAll extracts user data and uses GetAllVisible
2026-07-10 17:21:47 +02:00
REDCODE 0203644b3e feat: implement delta-based children endpoint with ?since parameter
- JobManager.GetChildren now accepts optional 'since' parameter
- Returns only children with LastChange/ModifiedAt > since
- Includes seenIds dedup between active and past children
- Returns response timestamp for next poll
- Controller sets x-delta-timestamp header
2026-07-10 12:49:43 +02:00
REDCODE dd43d069d5 feat: add ModifiedAt to JobRecord with delta query support
- Add ModifiedAt (DateTime?) to JobRecord
- Auto-set on Insert/Update in repository
- Add GetChildrenModifiedSince to interface + implementation
- EF Core migration AddModifiedAtToJobRecord
2026-07-10 12:49:40 +02:00
REDCODE 7dc5eff14b feat: add LastChange tracking to JobStatus
Set LastChange = UtcNow on every status/progress transition
for delta-based children sync.
2026-07-10 12:49:36 +02:00
REDCODE 5514bf89d9 fix: remove double-count of failed assets in master Done handler
The Interlocked.Increment(ref failedAssets) for Failed subjobs
caused double-counting: a subjob with N/12 failed assets would
add 1 (failed subjob) + 12 (individual assets) = 13, exceeding
the total asset count. Removed the Increment since subjob's
failedAssets is already the accurate per-asset count.
2026-07-10 12:17:50 +02:00
REDCODE 8ad378b649 fix: batch-processing subjobs report correct status on asset failures
Subjobs (SlaveJob) now check failedAssets after processing:
- All failed -> JobStatus.Fail()
- Some failed -> JobStatus.CompleteWithErrors()
- None failed -> JobStatus.Complete()

Also fixed race condition in master Done handler:
- Replaced non-atomic failedAssets += sub.failedAssets
- with Interlocked.Add(ref failedAssets, sub.failedAssets)

Affects: PreviewJob, ThumbnailJob, MetadataJob, PHashJob

Refs #76
2026-07-10 12:05:45 +02:00
REDCODE 3bddd4385d feat: add server-side password policy validation (admin bypass) 2026-07-10 10:22:36 +02:00
REDCODE 15b3fcedf1 feat: enforce old-password verification on own password change, allow admin override 2026-07-10 10:15:03 +02:00
REDCODE 652143d738 feat: allow users to update own albums and curators to update any album
- Users: changed from blanket Forbid to ownership check (can update own albums)
- Curators: changed from ownership check to full access (can update any album)
2026-07-09 23:46:02 +02:00
REDCODE 2f7cd3d7da fix: resolve UI issues #61, #62, #66
- #61: wrap standalone fallback div in cosplayer-card-img-wrap on
  Cosplayers page so placeholder icon gets proper sizing/positioning
- #62: add mobile breakpoint rule for modal-overlay so edit form
  appears centered on small screens instead of at page bottom
- #66: make cosplayer name in ImagePreview, AlbumDetail, AlbumCard,
  and Home asset tiles a clickable link to /cosplayer/{id}
- add CosplayerIds to AssetPreviewDto and populate via mapper for
  linked navigation from the home page image previewer
2026-07-09 22:36:07 +02:00
MrFastwind ede759b50b feat: migrate to UTC timestamps — remove legacy Npgsql timestamp behavior
- Remove EnableLegacyTimestampBehavior switch from Program.cs
- Add ConfigureConventions to DbContext pinning DateTime → timestamptz
- Add migration to convert all 17 DateTime columns across 5 tables
  (Albums, Assets, Users, People, JobRecords) with safe AT TIME ZONE 'UTC'
- Add Roslyn analyzer (MS001-MS004) enforcing UTC-only DateTime at compile time
  with code fix provider for auto-replacement
- Fix pre-existing DateTime.Now in AuthController.cs:119
- Add AllowMissingPrunePackageData to work around .NET 10 SDK issue
2026-07-09 21:43:46 +02:00
REDCODE c1aafc4223 refactor: replace individual albumPage/albumSize params with PagedParametersDto in person detail endpoint 2026-07-09 17:42:37 +02:00
REDCODE a8d06959b5 feat: person hard delete with album cascade, AlbumCard select mode, cosplayer list multi-select 2026-07-09 17:07:43 +02:00
REDCODE dbbb25da32 fix: create AlbumSearchParametersDto, add album pagination to person detail, fix duplicate XML param 2026-07-09 16:46:18 +02:00
REDCODE 9f180742cd fix(test): update name assertion to match renamed person 2026-07-09 16:40:32 +02:00
REDCODE e8c1a80264 test: all tests create their own data — create album returns ID, all mutations use self-created resources 2026-07-09 16:38:43 +02:00
REDCODE 7e16c77cb6 test: use real album from search for update test, not zero-GUID fallback 2026-07-09 16:36:01 +02:00
REDCODE 8f6a4396db test: add album update test without removePerson field 2026-07-09 16:34:47 +02:00
REDCODE 34fbbc91a0 chore(test): remove Swagger test — disabled in container environments 2026-07-09 16:32:47 +02:00
REDCODE 9be49ac9c6 fix(test): use response.body directly instead of JSON.parse (already parsed object) 2026-07-09 16:32:00 +02:00