Skip to main content

take_over

Function take_over 

Source
pub async fn take_over(
    pool: &PgPool,
    actor: &Actor,
    change_id: Uuid,
) -> AppResult<Change>
Expand description

Takes over a draft or rejected change of a deactivated author: the actor becomes its author and can edit, submit or cancel it (issue #173). It frees the revisions an abandoned change holds without an administrator.

§Invariants

  • Permission: CAD editor; the author is deactivated and the actor is an administrator or manages every affected project group (403); the change is a draft or rejected (409); the actor sees every item (403) and is not one of its reviewers – author and reviewer must differ (409).
  • Locks: the change row (FOR UPDATE).
  • Audit: change.handover (as the administrator’s hand-over), with taken_over: true.
  • Notifications / webhooks: none.
  • Data: created_by becomes the actor; reviews and items stay. As author the actor can no longer review it (four-eyes principle).
  • Atomic: one transaction.