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.
This commit is contained in:
1 parent
9dd425f765
commit
d5d21b7841
302 files changed
+20037
-3492
No files matched your search
@@ -59,17 +59,26 @@ func (s *Server) handleSaveRevisionAPI(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
var req struct {
|
||||
ObjectUUID string `json:"object_uuid"`
|
||||
Body string `json:"body"`
|
||||
Message string `json:"message"`
|
||||
Language string `json:"lang"`
|
||||
ContentType string `json:"content_type"`
|
||||
Filename string `json:"filename"`
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "private, no-store")
|
||||
if r.Method != http.MethodPost {
|
||||
w.Header().Set("Allow", "POST")
|
||||
api.WriteError(w, 405, "method_not_allowed", "POST required")
|
||||
return
|
||||
}
|
||||
|
||||
err := json.NewDecoder(r.Body).Decode(&req)
|
||||
var req struct {
|
||||
ObjectUUID string `json:"object_uuid"`
|
||||
Body string `json:"body"`
|
||||
Message string `json:"message"`
|
||||
Language string `json:"lang"`
|
||||
ContentType string `json:"content_type"`
|
||||
Filename string `json:"filename"`
|
||||
BaseRevision *string `json:"base_revision_uuid"`
|
||||
EditorPrincipal *string `json:"editor_principal_uuid"`
|
||||
}
|
||||
|
||||
err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 4<<20)).Decode(&req)
|
||||
if err != nil {
|
||||
api.WriteError(
|
||||
w,
|
||||
@@ -80,6 +89,17 @@ func (s *Server) handleSaveRevisionAPI(
|
||||
return
|
||||
}
|
||||
domainUUID := s.domainUUIDForRequest(r)
|
||||
if req.EditorPrincipal != nil {
|
||||
principal, e := s.store.PrincipalForSession(domainUUID, s.authTokenFromRequest(r))
|
||||
id := ""
|
||||
if e == nil && principal != nil {
|
||||
id = principal.UUID
|
||||
}
|
||||
if id != *req.EditorPrincipal {
|
||||
api.WriteError(w, 401, "editor_identity_changed", "editor identity changed; reopen with the original account")
|
||||
return
|
||||
}
|
||||
}
|
||||
if mode, _ := s.store.GetConfigInDomain(domainUUID, "authorization_mode"); mode == "enforcing" {
|
||||
principal, authErr := s.store.PrincipalForSession(domainUUID, s.authTokenFromRequest(r))
|
||||
if authErr != nil {
|
||||
@@ -109,15 +129,16 @@ func (s *Server) handleSaveRevisionAPI(
|
||||
}
|
||||
}
|
||||
|
||||
revision, err :=
|
||||
s.store.SaveRevisionContent(
|
||||
req.ObjectUUID,
|
||||
[]byte(req.Body),
|
||||
req.Message,
|
||||
req.Language,
|
||||
req.ContentType,
|
||||
req.Filename,
|
||||
)
|
||||
var revision *store.Revision
|
||||
if req.BaseRevision != nil {
|
||||
revision, err = s.store.SaveRevisionContentIfHead(req.ObjectUUID, []byte(req.Body), req.Message, req.Language, req.ContentType, req.Filename, *req.BaseRevision)
|
||||
} else {
|
||||
revision, err = s.store.SaveRevisionContent(req.ObjectUUID, []byte(req.Body), req.Message, req.Language, req.ContentType, req.Filename)
|
||||
}
|
||||
if errors.Is(err, store.ErrRevisionConflict) {
|
||||
api.WriteError(w, http.StatusConflict, "revision_conflict", "document changed; reload the language head before saving")
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
status := http.StatusInternalServerError
|
||||
@@ -143,5 +164,6 @@ func (s *Server) handleSaveRevisionAPI(
|
||||
"lang": revision.Language,
|
||||
"content_type": revision.ContentType,
|
||||
"filename": revision.Filename,
|
||||
"body": revision.Body,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user