feat(webhook): persist incoming provider messages

This commit is contained in:
2026-06-04 23:54:07 +08:00
parent b3865f9084
commit 5eb726b124
14 changed files with 535 additions and 84 deletions
+7 -2
View File
@@ -27,6 +27,7 @@ type LineWebhookHandler struct {
pipeline *linechannel.IncomingProcessor
service *linechannel.LineService
db *gorm.DB
persister *IncomingPersister
}
// NewLineWebhookHandler creates a LINE webhook handler for Gin integration.
@@ -36,6 +37,7 @@ func NewLineWebhookHandler(lineWebhook *linechannel.WebhookHandler, pipeline *li
pipeline: pipeline,
service: service,
db: db,
persister: NewIncomingPersister(db),
}
}
@@ -100,8 +102,11 @@ func (h *LineWebhookHandler) HandleLineWebhook(c *gin.Context) {
continue
}
if incomingMsg != nil {
applogger.L().Debugf("LINE webhook: processed event type=%s sender=%s",
event.Type, incomingMsg.SenderID)
if _, persistErr := h.persister.PersistIncoming(c.Request.Context(), inbox, incomingMsg); persistErr != nil {
applogger.L().Errorf("LINE webhook: persist event failed for inbox %d source_id=%s: %v", inbox.ID, incomingMsg.SourceID, persistErr)
continue
}
applogger.L().Debugf("LINE webhook: persisted event type=%s sender=%s", event.Type, incomingMsg.SenderID)
}
}