修复
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m25s

This commit is contained in:
2026-08-07 18:00:15 +08:00
parent 3421b5f106
commit 7aa03e91fb
12 changed files with 138 additions and 9 deletions

View File

@@ -3,8 +3,6 @@ package cardobservation
import (
"context"
"crypto/sha256"
"encoding/hex"
"strconv"
"time"
@@ -13,6 +11,7 @@ import (
"github.com/break/junhong_cmp_fiber/pkg/auditcontext"
"github.com/break/junhong_cmp_fiber/pkg/constants"
"github.com/break/junhong_cmp_fiber/pkg/errors"
"github.com/break/junhong_cmp_fiber/pkg/outboxid"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@@ -257,7 +256,5 @@ func workerObservationAudited(ctx context.Context) bool {
func realnameChangedEventID(cardID uint, observationID string) string {
prefix := "card-realname:"
digest := sha256.Sum256([]byte(strconv.FormatUint(uint64(cardID), 10) + ":" + observationID + ":changed"))
// 使用稳定摘要保留幂等语义,同时严格服从公共 Outbox 的字段长度上限。
return prefix + hex.EncodeToString(digest[:])[:constants.OutboxEventIDMaxLength-len(prefix)]
return outboxid.Stable(prefix, strconv.FormatUint(uint64(cardID), 10)+":"+observationID+":changed")
}