feat: announce material revisions on materials:{id}
- every revision bump (API writes and /bmadmin saves) enqueues
updated.jz.bm.material with {material_id, revision} in a savepoint
- the materials namespace authorizer allows a subscribe only to a
visible material the user may manage
- api.ManagesMaterials and api.CanWatchMaterial
This commit is contained in:
@@ -27,10 +27,18 @@ func staleRevision(sent *uint, stored uint) bool {
|
||||
|
||||
// revise bumps the revision of material id inside tx when its content
|
||||
// differs from before (models.ReviseMaterial). Every content writer of the
|
||||
// API calls it after its write.
|
||||
// API calls it after its write. A bump also enqueues the live heads-up on
|
||||
// tx (D-20), published only when the write commits; its failure never fails
|
||||
// the write.
|
||||
func (h *Handlers) revise(ctx context.Context, tx *gorm.DB, id uint, before string) error {
|
||||
_, _, err := models.ReviseMaterial(tx.WithContext(ctx), id, before)
|
||||
return err
|
||||
rev, bumped, err := models.ReviseMaterial(tx.WithContext(ctx), id, before)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if bumped {
|
||||
h.Revisions.Revised(ctx, tx, id, rev)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// writeConflict answers 409 to a write that sent a stale revision, with the
|
||||
|
||||
Reference in New Issue
Block a user