V3 S3 : correction des faits (fiche document + correct_facts)
Backend : CorrectFacts (editor+, validation Go -> 400 jamais 500), op outbox correct_facts (full-replace jeu user), PATCH /files/:id/facts (renvoie jeu complet). Tests service + sync + handlers. Mobile (Room v20) : table resource_facts + FactsDao, FactsRepository (sync remplace-en-bloc, correction optimiste + outbox atomique), fiche « Ce qu'on a compris » sur le viewer (chips, suggéré grisé, édition par type, reset auto), bouton viewer si processed, FR/EN. Contrat docs/api-v1.md, V3.md (S1-S3 livrés, FTS -> v21).
This commit is contained in:
+24
-1
@@ -31,6 +31,8 @@ const (
|
||||
OpTrashResource = "trash_resource"
|
||||
OpRestoreResource = "restore_resource"
|
||||
OpPurgeResource = "purge_resource"
|
||||
// V3 corrections (S3) : remplace le jeu `user` des faits (editor+).
|
||||
OpCorrectFacts = "correct_facts"
|
||||
)
|
||||
|
||||
// SyncOperation is one outbox entry (shadow of mobile PendingOperationRow).
|
||||
@@ -98,6 +100,10 @@ type reportBytesPayload struct {
|
||||
HasBytes *bool `json:"hasBytes"`
|
||||
}
|
||||
|
||||
type correctFactsPayload struct {
|
||||
Facts []FactDTO `json:"facts"`
|
||||
}
|
||||
|
||||
func classifySyncError(err error) (string, string) {
|
||||
switch {
|
||||
case errors.Is(err, repository.ErrNameConflict):
|
||||
@@ -206,7 +212,8 @@ func validateSyncOp(op *SyncOperation) error {
|
||||
switch op.Operation {
|
||||
case OpCreateResource, OpUpdateMetadata, OpMoveResource, OpDeleteResource,
|
||||
OpShare, OpRevokeShare, OpUpdateShare, OpCreateLink, OpRevokeLink,
|
||||
OpReportBytes, OpTrashResource, OpRestoreResource, OpPurgeResource:
|
||||
OpReportBytes, OpTrashResource, OpRestoreResource, OpPurgeResource,
|
||||
OpCorrectFacts:
|
||||
default:
|
||||
return errors.New("unknown operation " + op.Operation)
|
||||
}
|
||||
@@ -400,6 +407,22 @@ func (s *Resources) applySyncOp(ownerID, deviceID string, op *SyncOperation) err
|
||||
case OpReportBytes:
|
||||
return s.applyReportBytesOp(ownerID, deviceID, resourceID, op)
|
||||
|
||||
case OpCorrectFacts:
|
||||
// S3 : même garde que CorrectFacts (editor+, A8) — une ressource
|
||||
// visible sans droit de mutation n'est pas corrigeable (NOT_FOUND,
|
||||
// pas d'oracle). Le payload porte le jeu `user` complet
|
||||
// (full-replace, jamais de diff).
|
||||
var p correctFactsPayload
|
||||
if err := json.Unmarshal(op.Payload, &p); err != nil {
|
||||
return errors.New("invalid payload: " + err.Error())
|
||||
}
|
||||
for i, f := range p.Facts {
|
||||
if _, err := validateFactParam(i, f); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return s.CorrectFacts(ownerID, resourceID, p.Facts)
|
||||
|
||||
default:
|
||||
return errors.New("unknown operation " + op.Operation)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user