refactor: remove ExternalSource and ExternalID from Conversation model and related services, update references to use ChannelID instead

This commit is contained in:
mlogclub
2026-04-27 19:04:10 +08:00
parent 24105781d9
commit b3ef55b04e
21 changed files with 183 additions and 136 deletions
+11 -1
View File
@@ -862,7 +862,7 @@ func (s *ticketService) CreateFromConversation(req request.CreateTicketFromConve
Title: title,
Description: description,
Source: string(enums.TicketSourceConversation),
Channel: string(conversation.ExternalSource),
Channel: s.resolveConversationChannel(conversation),
CustomerID: conversation.CustomerID,
ConversationID: conversation.ID,
TagIDs: req.TagIDs,
@@ -1845,6 +1845,16 @@ func parseOptionalDateTime(value string) (*time.Time, error) {
return nil, fmt.Errorf("invalid datetime")
}
func (s *ticketService) resolveConversationChannel(conversation *models.Conversation) string {
if conversation == nil || conversation.ChannelID <= 0 {
return ""
}
if channel := ChannelService.Get(conversation.ChannelID); channel != nil {
return channel.ChannelType
}
return ""
}
func diffMinutes(start *time.Time, end time.Time) int {
if start == nil || start.IsZero() {
return 0