pub async fn create(
pool: &PgPool,
actor: &Actor,
input: NewItem,
) -> AppResult<Revision>Expand description
Creates an item together with its first revision A (in work) and
returns that revision.
§Invariants
- Permission: editor role (403 otherwise); a project group is required (400), it must exist and be visible (400 “Unknown project”), not archived (400) and the actor a member of it (403).
- Locks: the project group row (
FOR SHARE, so a visibility change cannot move the counters meanwhile) and the number counter row, which stays locked until the commit. - Audit:
item.create. - Notifications: none; the creator only starts watching the item.
- Webhooks: none.
- Data: a generated number steps the group’s counter (numbers already
taken are skipped); the first revision
Ais in work and checked out by the creator. A failed creation rolls the counter back with it. - Atomic: one transaction; concurrent creations get distinct numbers
(
tests/numbering_and_watches.rs).