feat(invitations): send invitations into the candidate inbox atomically

This commit is contained in:
shira committed 2026-10-09 16:50:36 +03:00
1 parent fc35e27af5
commit 1a067221f7
46 files changed
+3276 -113

No files matched your search

+12
View File
@@ -232,7 +232,11 @@ func RestoreInvitation(stored StoredInvitation) (Invitation, error) {
return Invitation{}, fmt.Errorf("%s - validate terms: %w", location, err)
}
stored.Terms = stored.Terms.Clone()
// Every time of an invitation is kept in UTC, whatever the time zone of
// the storage session, so a response is the same after a read.
stored.CreatedAt, stored.UpdatedAt = stored.CreatedAt.UTC(), stored.UpdatedAt.UTC()
stored.ResponseDeadlineAt, stored.DeliveredAt = utcInvitationTime(stored.ResponseDeadlineAt), utcInvitationTime(stored.DeliveredAt)
stored.ViewedAt, stored.RespondedAt = utcInvitationTime(stored.ViewedAt), utcInvitationTime(stored.RespondedAt)
if stored.Need != nil {
need := *stored.Need
stored.Need = &need
@@ -286,6 +290,14 @@ func storedInvitationLifecycleDefect(stored StoredInvitation) string {
return ""
}
func utcInvitationTime(value *time.Time) *time.Time {
if value == nil {
return nil
}
converted := value.UTC()
return &converted
}
func validInvitationTime(value time.Time) bool {
return !value.IsZero() && value.Year() >= 1 && value.Year() <= 9999
}