feat(audit): correlate outbound card callbacks

This commit is contained in:
姚章浩
2026-07-15 14:00:16 +08:00
parent 1b0b0fb8ed
commit 148c1be452
9 changed files with 27 additions and 3 deletions
+2
View File
@@ -226,6 +226,8 @@ type Message struct {
SourceChannelID string `json:"source_channel_id,omitempty" gorm:"type:varchar(36);default:''"`
// SourceMessageID is the platform message identifier used for end-to-end correlation.
SourceMessageID string `json:"source_message_id,omitempty" gorm:"type:varchar(128);default:''"`
// SourceDeliveryID correlates outbound cards/messages with later platform callbacks.
SourceDeliveryID string `json:"source_delivery_id,omitempty" gorm:"type:varchar(128);default:''"`
// SourceUserID records the platform user for this individual message.
SourceUserID string `json:"source_user_id,omitempty" gorm:"type:varchar(128);default:''"`
// SourceChatID records the platform conversation or group identifier.
@@ -23,6 +23,7 @@ func TestMessageAuditMigrationCoversModelFields(t *testing.T) {
"source_platform",
"source_channel_id",
"source_message_id",
"source_delivery_id",
"source_user_id",
"source_chat_id",
"source_thread_id",
+3 -1
View File
@@ -11,7 +11,8 @@ func TestMessageCarriesAuditMetadata(t *testing.T) {
ID: "message-1",
SourcePlatform: "dingtalk",
SourceChannelID: "channel-1",
SourceMessageID: "external-message-1",
SourceMessageID: "platform-message-1",
SourceDeliveryID: "card-track-1",
SourceUserID: "user-1",
SourceChatID: "chat-1",
SourceThreadID: "thread-1",
@@ -37,6 +38,7 @@ func TestMessageCarriesAuditMetadata(t *testing.T) {
if decoded.SourcePlatform != original.SourcePlatform ||
decoded.SourceChannelID != original.SourceChannelID ||
decoded.SourceMessageID != original.SourceMessageID ||
decoded.SourceDeliveryID != original.SourceDeliveryID ||
decoded.SourceUserID != original.SourceUserID ||
decoded.SourceChatID != original.SourceChatID ||
decoded.SourceThreadID != original.SourceThreadID {