added messages templates
This commit is contained in:
parent
e8dc967e6a
commit
7cd1f64d0d
29 changed files with 1266 additions and 84 deletions
|
|
@ -52,11 +52,24 @@ func SameLoginCodeFingerprint(stored []byte, expected [sha256.Size]byte) bool {
|
|||
// RestoreLoginCodeDeliveryMessage reconstructs the immutable first result from
|
||||
// a compact receipt. The secret code is not duplicated in the receipt: exact
|
||||
// replay has already proven the supplied code fingerprint matches.
|
||||
func RestoreLoginCodeDeliveryMessage(userID int64, code string, date int, privateMessageID int64, messageBoxID, pts int) (domain.Message, error) {
|
||||
//
|
||||
// template is the caller's currently-resolved login-code message template
|
||||
// (see domain.ResolveLoginCodeMessageTemplate), not a historical snapshot of
|
||||
// whatever template was in effect at original-delivery time -- the receipt
|
||||
// does not persist that. In the ordinary case (a same-request or
|
||||
// near-immediate idempotent retry, e.g. resendCode) the template cannot have
|
||||
// changed in between, so this is a no-op distinction; if an admin edits the
|
||||
// template in the narrow window between the original delivery and a later
|
||||
// replay of the same phone_code_hash, the replay's reconstructed Body/Entities
|
||||
// reflect the *current* template rather than the one actually persisted in
|
||||
// the messages table, mirroring this codebase's established "identity is
|
||||
// always read fresh, never versioned" convention (see internal/identity's
|
||||
// package doc comment) rather than a regression specific to this function.
|
||||
func RestoreLoginCodeDeliveryMessage(userID int64, template, code string, date int, privateMessageID int64, messageBoxID, pts int) (domain.Message, error) {
|
||||
if privateMessageID <= 0 || messageBoxID <= 0 || messageBoxID > domain.MaxMessageBoxID || pts <= 0 {
|
||||
return domain.Message{}, fmt.Errorf("restore login code delivery: %w: uid=%d box=%d pts=%d", domain.ErrLoginCodeDeliveryInvalid, privateMessageID, messageBoxID, pts)
|
||||
}
|
||||
msg, err := domain.OfficialLoginCodeMessage(userID, code, date)
|
||||
msg, err := domain.OfficialLoginCodeMessage(userID, template, code, date)
|
||||
if err != nil {
|
||||
return domain.Message{}, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue