Files
Anya Tokugawa d5d21b7841
Build and publish container images / images (push) Successful in 9m34s
Release container images / release (push) Successful in 36s
Refactor architecture into eight components and consolidate reliability work
Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts.

Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation.

Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
2026-11-01 15:23:31 +09:00

71 lines
1.9 KiB
Go

package schutzaria
import (
"path"
"strings"
)
type UserSpacePathPolicy struct {
Path string `json:"path"`
Visibility string `json:"visibility"`
}
type UserSpacePolicy struct {
PrincipalUUID string `json:"principal_uuid"`
Username string `json:"username"`
ProfileVisibility string `json:"profile_visibility"`
AvatarVisibility string `json:"avatar_visibility"`
RootVisibility string `json:"root_visibility"`
DescendantVisibility string `json:"descendant_visibility"`
Version int64 `json:"version"`
DomainAllowsPublic bool `json:"domain_allows_public"`
Overrides []UserSpacePathPolicy `json:"overrides"`
}
func UserSpaceVisibilityRank(value string) int {
switch value {
case "private":
return 0
case "domain":
return 1
case "public":
return 2
default:
return -1
}
}
func UserSpaceDocumentPath(username, value string, descendant bool) bool {
root := "/u/" + username
if value != path.Clean(value) || strings.ContainsAny(value, "\\\x00\r\n") {
return false
}
if descendant {
if !strings.HasPrefix(value, root+"/") {
return false
}
rest := strings.TrimPrefix(value, root+"/")
return rest != "" && !strings.HasPrefix(rest, "_/") && rest != "_"
}
return value == root
}
func EffectiveUserSpaceVisibility(p UserSpacePolicy, target string) string {
root := "/u/" + p.Username
if target == root {
return p.RootVisibility
}
if !UserSpaceDocumentPath(p.Username, target, true) {
return "private"
}
visibility := p.DescendantVisibility
for _, item := range p.Overrides {
if target == item.Path || strings.HasPrefix(target, strings.TrimRight(item.Path, "/")+"/") {
if UserSpaceVisibilityRank(item.Visibility) < UserSpaceVisibilityRank(visibility) {
visibility = item.Visibility
}
}
}
return visibility
}