Sharing backend: shares CRUD + ACL enforcement everywhere (#16)
Build image / build-and-push (push) Successful in 4s
Build image / build-and-push (push) Successful in 4s
Co-authored-by: Steve Dudenhoeffer <[email protected]>
This commit was merged in pull request #35.
This commit is contained in:
@@ -121,9 +121,19 @@ func (s *Service) UpdatePlanting(ctx context.Context, actorID, plantingID int64,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
originalPlantID := pl.PlantID
|
||||
applyPlantingPatch(pl, patch)
|
||||
// The plant may have changed; the (possibly new) plant must be visible.
|
||||
plant, err := s.visiblePlant(ctx, actorID, pl.PlantID)
|
||||
// Fetch the plop's plant for the derived count. Only when the actor is
|
||||
// actually CHANGING the plant (new id ≠ old) is the new plant gated on
|
||||
// visibility — an existing plop may reference a plant the actor can't see
|
||||
// (e.g. a shared editor in the owner's garden using the owner's private
|
||||
// plant), and a no-op plantId resend must not break editing it.
|
||||
var plant *domain.Plant
|
||||
if pl.PlantID != originalPlantID {
|
||||
plant, err = s.visiblePlant(ctx, actorID, pl.PlantID)
|
||||
} else {
|
||||
plant, err = s.store.GetPlant(ctx, pl.PlantID)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user