Skip to content

feat(event): attach photos to repair events - #234

Merged
wen-templari merged 8 commits into
mainfrom
feat/event-photos
Oct 15, 2026
Merged

wen-templari merged 8 commits into
mainfrom
feat/event-photos

Conversation

@m1ngsama

@m1ngsama m1ngsama commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Members need to record on-site photos on repair tickets, for later review and as evidence of the device's condition.

Needs your decision

  • Consul weekend/prod needs aliyun.access_key_id and aliyun.access_key_secret with write access to bucket sunday-res, ideally a RAM user limited to that bucket (util/photo.go).
  • Admins can now open any event's detail, which includes the client's phone and QQ (router/event.go).
  • Every request body is now capped at 25 MB (router/main.go). Please check that the reverse proxy accepts bodies that large on /member/events/*/photos; nginx defaults to 1 MB.

What changed

  • POST /member/events/{EventId}/photos accepts up to 20 photos per event, 5 MB each, WebP or JPEG by content sniffing. Only the assigned member or an admin can upload, and only while the event is accepted or committed. There is no delete endpoint.
  • Photos are private objects under weekend/events/{id}/, recorded in a new event_photo table (migration 000008).
  • GET /member/events/{id} and GET /client/events/{id} return photos with 1-hour signed URLs. Public endpoints do not return photos.
  • Status and the 20-photo limit are checked again under a row lock on the event, so concurrent uploads cannot exceed it.
  • If any photo in a batch fails to store, the photos already uploaded from that batch are deleted. Storage failures return 500 and are logged; validation failures return 422.
  • Only event detail and uploads load photos, so other event responses carry no photo URLs.
  • The unused /upload stub, util.Upload and its docs page are removed.

Verification

  • go test ./... passes. With TEST_DB_DATASOURCE set, a repo test runs two concurrent 15-photo uploads against Postgres and checks that only one succeeds.
  • A local run against Postgres with a Logto stub covered permissions, size, type, status, the 25 MB cap, and storage failure (500, no rows written). Migrations ran 7→8, down and up, and on a fresh database.
  • Not verified: a real OSS upload. Without keys, only the failure path and the signed URL format were checked.

m1ngsama and others added 3 commits October 15, 2026 10:51
Load and sign photos only for event detail and uploads, so action
responses no longer carry unsigned photo urls. Check status and the
20-photo limit under a row lock, delete objects from a failed batch,
close uploaded file handles, and reuse the OSS client until the
credentials change.
@wen-templari
wen-templari merged commit 297f7d1 into main Oct 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants