Move pending signature requests on minor publish

When a new minor version is published, still-REQUESTED signature requests
on the previous version now move onto the newly published version, keeping
the same signature row so the notification schedule (count and last-notified
time) is preserved. SIGNED signatures are left untouched.

Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
Sacha Al Himdani
2026-06-24 10:51:32 +02:00
parent 45b434dd99
commit 612e9cbc22
3 changed files with 151 additions and 0 deletions

View File

@@ -2889,9 +2889,31 @@ func (s *DocumentService) publishMinorVersionInTx(
return nil, nil, err
}
if err := s.moveRequestedSignaturesToVersionInTx(ctx, scope, tx, documentVersion.ID); err != nil {
return nil, nil, err
}
return document, documentVersion, nil
}
// moveRequestedSignaturesToVersionInTx carries every still-pending signature
// request from a prior minor of the same major onto the newly published minor
// version. The new minor supersedes the previous one while keeping the same
// signing obligations, so REQUESTED signatures follow along with their
// notification schedule (time and count) intact. SIGNED signatures stay put.
func (s *DocumentService) moveRequestedSignaturesToVersionInTx(
ctx context.Context, scope coredata.Scoper,
tx pg.Tx,
documentVersionID gid.GID,
) error {
signatures := &coredata.DocumentVersionSignatures{}
if err := signatures.MoveRequestedToVersionWithinMajor(ctx, tx, scope, documentVersionID); err != nil {
return fmt.Errorf("cannot move signature requests to the newly published minor version: %w", err)
}
return nil
}
func (s *DocumentService) generateAndUploadPublicationPDF(
ctx context.Context, scope coredata.Scoper,
documentVersion *coredata.DocumentVersion,