release 1.1.0 : sync V2 (upload, download, purge, placements, rétention, groupes)
Release / release-apk (push) Successful in 9m25s
Release / release-docker (push) Successful in 33s
CI / docker (push) Successful in 7s
CI / lint-backend (push) Successful in 1m29s
CI / lint-mobile (push) Failing after 7m46s
CI / test-backend (push) Successful in 1m30s
CI / test-mobile (push) Successful in 9m27s
CI / build-backend (push) Successful in 47s
Release / release-apk (push) Successful in 9m25s
Release / release-docker (push) Successful in 33s
CI / docker (push) Successful in 7s
CI / lint-backend (push) Successful in 1m29s
CI / lint-mobile (push) Failing after 7m46s
CI / test-backend (push) Successful in 1m30s
CI / test-mobile (push) Successful in 9m27s
CI / build-backend (push) Successful in 47s
This commit is contained in:
+38
-16
@@ -67,10 +67,11 @@ type movePayload struct {
|
||||
}
|
||||
|
||||
type sharePayload struct {
|
||||
GranteeUserID string `json:"granteeUserId"`
|
||||
Access string `json:"access"`
|
||||
Inherit *bool `json:"inherit"`
|
||||
ExpiresAt *int64 `json:"expiresAt"`
|
||||
GranteeUserID string `json:"granteeUserId"`
|
||||
GranteeGroupID string `json:"granteeGroupId"`
|
||||
Access string `json:"access"`
|
||||
Inherit *bool `json:"inherit"`
|
||||
ExpiresAt *int64 `json:"expiresAt"`
|
||||
}
|
||||
|
||||
type revokeSharePayload struct {
|
||||
@@ -99,6 +100,8 @@ func classifySyncError(err error) (string, string) {
|
||||
return "NOT_FOUND", "target resource or folder not found"
|
||||
case errors.Is(err, repository.ErrGranteeNotFound):
|
||||
return "GRANTEE_NOT_FOUND", "the specified user does not exist"
|
||||
case errors.Is(err, repository.ErrGroupNotFound):
|
||||
return "GROUP_NOT_FOUND", "the specified group does not exist"
|
||||
case errors.Is(err, repository.ErrPayloadMismatch):
|
||||
return "INVALID_REQUEST", "operation replayed with different payload"
|
||||
case errors.Is(err, errCycle):
|
||||
@@ -383,23 +386,22 @@ func (s *Resources) applyShareOp(ownerID, resourceID string, op *SyncOperation)
|
||||
if err := json.Unmarshal(op.Payload, &p); err != nil {
|
||||
return errors.New("invalid payload: " + err.Error())
|
||||
}
|
||||
if p.GranteeUserID == "" {
|
||||
return errors.New("payload.granteeUserId required")
|
||||
// Cible : exactement un principal (user XOR groupe, V2-6).
|
||||
isUser := p.GranteeUserID != ""
|
||||
isGroup := p.GranteeGroupID != ""
|
||||
if isUser == isGroup {
|
||||
return errors.New("payload requires exactly one of granteeUserId, granteeGroupId")
|
||||
}
|
||||
if !resourceIDPattern.MatchString(p.GranteeUserID) {
|
||||
if isUser && !resourceIDPattern.MatchString(p.GranteeUserID) {
|
||||
return errors.New("payload.granteeUserId must be 32 lowercase hex chars")
|
||||
}
|
||||
if isGroup && !resourceIDPattern.MatchString(p.GranteeGroupID) {
|
||||
return errors.New("payload.granteeGroupId must be 32 lowercase hex chars")
|
||||
}
|
||||
rank := repository.AccessFromString(p.Access)
|
||||
if rank < repository.AccessViewer || rank > repository.AccessEditor {
|
||||
return errors.New("payload.access must be viewer, commenter, or editor")
|
||||
}
|
||||
// Validate grantee exists and is active.
|
||||
if _, err := s.Repository.Users.GetByID(p.GranteeUserID); err != nil {
|
||||
if errors.Is(err, repository.ErrNotFound) {
|
||||
return repository.ErrGranteeNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
inherit := true
|
||||
if p.Inherit != nil {
|
||||
inherit = *p.Inherit
|
||||
@@ -412,8 +414,28 @@ func (s *Resources) applyShareOp(ownerID, resourceID string, op *SyncOperation)
|
||||
}
|
||||
expiresAt = &t
|
||||
}
|
||||
if err := s.Repository.Shares.Upsert(resourceID, p.GranteeUserID, p.Access, inherit, expiresAt, ownerID); err != nil {
|
||||
return err
|
||||
if isUser {
|
||||
// Validate grantee exists and is active.
|
||||
if _, err := s.Repository.Users.GetByID(p.GranteeUserID); err != nil {
|
||||
if errors.Is(err, repository.ErrNotFound) {
|
||||
return repository.ErrGranteeNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
if err := s.Repository.Shares.Upsert(resourceID, p.GranteeUserID, p.Access, inherit, expiresAt, ownerID); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Validate group exists (any group : ids are unguessable, no enum).
|
||||
if _, err := s.Repository.Groups.Get(p.GranteeGroupID); err != nil {
|
||||
if errors.Is(err, repository.ErrNotFound) {
|
||||
return repository.ErrGroupNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
if err := s.Repository.Shares.UpsertGroup(resourceID, p.GranteeGroupID, p.Access, inherit, expiresAt, ownerID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Bump resource updated_at so the grantee's delta snapshot picks it up.
|
||||
// Scopé owner (ExistsOwner vérifié plus haut) : TouchOwned, jamais le
|
||||
|
||||
Reference in New Issue
Block a user