Skip to content

feat(remote-storage): simplify settings with explicit path, public URL and QR link - #1677

Draft
fmiccolis wants to merge 7 commits into
PhotoboothProject:devfrom
fmiccolis:feature/remote-storage-settings
Draft

fmiccolis wants to merge 7 commits into
PhotoboothProject:devfrom
fmiccolis:feature/remote-storage-settings

Conversation

@fmiccolis

Copy link
Copy Markdown
Contributor

Prerequisites checklist

What is the purpose of this pull request? (put an "x" next to an item)

  • Documentation update
  • Bug fix
  • New feature
  • Other, please explain:

What changes did you make? (Give an overview)

Stacked on #1603. This branch is built on top of the async upload PR, so until that one is merged the diff also shows its commits. Only the last two commits belong to this PR; it is opened as a draft for that reason.

This is the follow-up announced in #1603: the remote storage (FTP/SFTP) settings are rewritten so that they say exactly what they do. The old settings were modelled on one specific hosting layout and overlapped each other.

New settings

Old New
baseURL host
baseFolder + folder + implicit title sub-folder path: the full remote folder, used exactly as written
website + urlTemplate url: the public URL of that folder
useForQr removed: QR codes use the remote storage as soon as url is set
hard-coded /images/ + qr.append_filename qr_link: what is appended to url for a single photo
  • %title% is the only placeholder of path and url. It is replaced by the slug of the title, so changing the title for every event still gives a folder (and gallery) per event.
  • qr_link defaults to /images/%file% (unchanged behaviour). /?photo=%file% opens the photo inside the gallery page; empty links to the gallery.
  • Example: path = www.example.com/photobooth/%title%, url = https://example.com/photobooth/%title%, title My Event → upload to /www.example.com/photobooth/my-event/images/<file>, QR code https://example.com/photobooth/my-event/images/<file>.

Problems of the old settings that this fixes

  • folder was slugified for the upload path but used raw in the QR URL, so any value containing e.g. a slash produced a QR code pointing to a different place than the upload.
  • The manual described folder as /path/to/directory, which the slug made impossible, and documented urlTemplate placeholders (%baseFolder, %date) that were never implemented.
  • The QR link was built twice (api/qrcode.php, api/print.php); it now comes from one method of RemoteStorageService.

Test connection

  • Tests the values currently entered in the form instead of the saved ones (before, unsaved values were sent but ignored).
  • Now requires the admin session and the CSRF token.
  • Reports missing host/username, shows the reason returned by the server on failure, and on success shows the resolved remote folder and an example QR code link.
  • The admin toast showed the default "success" headline on a red background when the test failed; it now shows the translated outcome.
  • The default port follows the selected connection type (21/22) unless it was customised.

Error reporting

  • Flysystem wraps e.g. a failed login into creating parent directory failed. The messages of the previous exceptions are now logged and stored in the upload queue too, so the real cause is visible.

Bundled gallery template

Docs / translations

  • FAQ section rewritten, including an upgrade table.
  • en and it manual texts rewritten. In the other languages the keys of the removed settings are deleted, and the few texts that described the old behaviour are removed so they fall back to English.

Breaking change

The old settings are not migrated: after updating, the remote storage settings have to be entered again (see the upgrade table in the FAQ). I think this is acceptable for a feature with few users and it keeps the code free of legacy handling, but I can add a migration if you prefer.

Is there anything you'd like reviewers to focus on?

  • Whether dropping the old keys without migration is acceptable.
  • The config section is still called ftp although it also covers SFTP; I left the key untouched to limit the change.
  • api/testFtpConnection.php now goes through admin/admin_boot.php and checkCsrfOrFail().

Tested on a live installation with a real FTP server: connection test (failure with wrong credentials), upload of pictures and thumbnails to the folder resolved from path, queue draining. npm run build was run on that installation and npx eslint is clean on the touched JS files; all touched PHP files were syntax-checked. The ?photo= view of the bundled template has not been exercised against a remote server yet, and no automated tests were added.

AI used to create this Pull Request?

Yes. This PR was developed with Claude Code (Anthropic). The AI analysed the existing settings, proposed the new model and wrote the implementation; I decided the design (single path / public URL, configurable QR link, no automatic migration) and tested the upload flow on a real installation against my FTP server.

fmiccolis and others added 6 commits November 9, 2026 15:12
- Environment & network tab: one QR code per IPv4 address encoding the
  photobooth URL on that network, to open it from another device
- New remote storage queue tab showing per-file upload status, attempts,
  errors and timestamps (works with the existing auto-refresh toggle)
- Add missing label for the remote storage log tab

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The build workflow runs "npm run build", which sorts en.json with
localeCompare and then requires a clean working tree. The new
remoteUpload* keys were placed after "rembglog" but localeCompare
orders them after "remoteStorageTemplate", so the build modified the
file and the status check failed. it.json is aligned for consistency.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The bundled gallery template ignores the photo query parameter, so the
/?photo=<file> link opened the whole gallery instead of the picture.
Keep the existing link; the deep link will be proposed separately
together with template support.
…L and QR link

Replace the overlapping remote storage settings with explicit ones:

- `path`: full remote folder, used as written (replaces `baseFolder`,
  `folder` and the implicit title sub-folder)
- `url`: public URL of that folder (replaces `website` and `urlTemplate`);
  when set, QR codes point to the remote storage, so `useForQr` is removed
- `qr_link`: what is appended to the URL for a single photo, e.g.
  `/images/%file%` (default) or `/?photo=%file%`
- `baseURL` is renamed to `host`

`%title%` is the only placeholder of `path` and `url` and is replaced by
the slug of the title, so changing the title still creates a folder per
event.

Also:
- the QR code link is built in one place for screen and print
- "Test connection" tests the values entered in the form, requires the
  admin session and CSRF token, and shows the resolved folder and an
  example QR code link
- the default port follows the selected connection type
- the bundled gallery template opens the photo given by `?photo=` and no
  longer builds broken links when the request has a query string
- FAQ and manual texts updated

BREAKING CHANGE: the old settings are not migrated, see the upgrade
table in the FAQ.
…ection tests

- Flysystem wraps e.g. a failed login into "creating parent directory
  failed": log and store the messages of the previous exceptions too
- "Test connection" shows the reason returned by the server
- the admin toast showed the default "success" headline in red when the
  test failed: show the translated outcome instead

@reloxx13 reloxx13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of PR #1677

  • P1: Migrate saved FTP settings before removing legacy keys. Existing baseURL, baseFolder, folder, website and urlTemplate values are discarded during normalization. Preserve the old upload paths and useForQr opt-in.
  • P1: Restore explicit admin/rental authorization for reboot and shutdown. With login disabled, CSRF alone permits anonymous power actions.
  • P2: Delete remote copies for pending and failed queue entries too. A successful image write followed by a failed thumbnail write leaves a publicly accessible image behind.

All three corrections are prepared locally on feature/remote-storage-settings, based on 90a4cda. They have not been pushed.

Validation: DDEV PHPUnit passed (35 tests, 53 assertions); PHPStan passed; changed PHP files passed PHP-CS-Fixer dry-run. Isolated endpoint-block checks passed with stubs. Global formatting check has an unrelated existing failure in private/scripts/upload-images-to-ftp.php.

Migrate legacy FTP paths and QR opt-in without replacing explicit new settings. Require admin or rental authorization for power commands even when login is disabled. Delete remote copies after partial upload failures.

@reloxx13 reloxx13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the three reported findings on 20ef523: legacy FTP settings and QR opt-in are migrated, reboot/shutdown require admin or rental authorization, and remote deletion includes partially failed uploads. All three findings are addressed. Validation: 35 PHPUnit tests (53 assertions), PHPStan, and scoped PHP-CS-Fixer passed. Endpoint branches were checked with isolated stubs; no live FTP or power commands were executed. Global formatting has an unrelated existing failure in private/scripts/upload-images-to-ftp.php. The corrective commit was prepared and pushed by this same assistant session.

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