feat(sharing): master switch for public share links, and a policy tab that reads in decision order #352
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "sharing-page"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Built test-first. Three commits: RED (field + tests, one failing), GREEN (four lines of enforcement), then the UI.
The switch
settings.ShareLinksDisabledturns off creation of new public share links instance-wide.shareCreaterejects with400 policy: public share links are turned off on this server, checked before the password and expiry rules, so there is no combination of other settings that lets a link through.Stored negative, deliberately. A
ShareLinksEnabled boolwould default to Go's zero value —false— and every existing instance would silently lose share links on upgrade, because itssettings.jsonhas no such key.ShareUploadsForbiddenalready solves this the same way. The UI inverts both, so the labels read the right way round without a config migration.Three tests, each pinning a claim that can break independently:
TestShareLinksDisabledRejectsCreationTestShareLinksEnabledWhenUnsetTestShareLinksDisabledLeavesExistingLinksOnly the first was red before the enforcement commit; the other two were written to fail loudly if the implementation broke behaviour it had no business touching. That was checked, not assumed — the RED run asserted the enforcement test failed on its
want 400assertion and that the other two already passed.The policy tab
Rows now run capability → constraint → defaults → timings: whether links may exist at all, whether they must carry a password, whether they may take uploads, whether uploads are on by default, then the two expiry ceilings. Previously the two dropdowns came first and the switches after, which is schema order, not decision order.
Forbid upload linksbecomesAllow upload links— same stored field, inverted in the UI. Labels shortened now that the page title supplies the context (Default share expiry→Default expiry). Page description changed from "Instance-wide share link policy." to "Who may create share links, and the limits the server enforces on them."Nine i18n keys upserted across four languages; two that lost their last caller (
sdNoUpload,shareForbidUploads) were removed, and the splice asserted no references survive.Not in this PR
Non-operator visibility — a regular user still discovers the policy by being rejected after filling in the dialog. That is #351, with the three candidate designs and the argument against each written up.
Verification
go build ./...,go vet,go test ./internal/api/... ./internal/settings/...all pass.node --checkon the extracted script blocks passes. Row order asserted programmatically rather than eyeballed.Adds settings.ShareLinksDisabled and three tests. Only the enforcement test fails; the other two already hold and are here to pin behaviour the implementation must not break: - the zero value must leave sharing ON, since an upgrading instance has no such key in settings.json; - disabling must not revoke links that already exist. Field is stored negative for exactly that first reason.