37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package chat
|
|
|
|
import (
|
|
"hfb_sys/backend/internal/model"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// DefaultSupportAdminID 导出默认客服选择逻辑,供其他业务模块建群时复用。
|
|
func DefaultSupportAdminID(tx *gorm.DB) uint64 {
|
|
return defaultSupportAdminID(tx)
|
|
}
|
|
|
|
// SendSystemMessageForTx 在事务内发送系统文本消息。
|
|
func SendSystemMessageForTx(tx *gorm.DB, conversationID uint64, content string) error {
|
|
return sendSystemMessage(tx, conversationID, content)
|
|
}
|
|
|
|
// SendImageMessageForTx 在事务内发送系统图片消息。
|
|
func SendImageMessageForTx(tx *gorm.DB, conversationID uint64, content, imageURL string) error {
|
|
if content == "" {
|
|
content = "👇 请扫码联系客服"
|
|
}
|
|
message := model.ChatMessage{
|
|
ConversationID: conversationID,
|
|
SenderType: "system",
|
|
SenderRole: "system",
|
|
ContentType: "image",
|
|
Content: content,
|
|
AttachmentURLS: encodeStringList([]string{imageURL}),
|
|
}
|
|
if err := tx.Create(&message).Error; err != nil {
|
|
return err
|
|
}
|
|
return updateConversationLastMessage(tx, conversationID, &message)
|
|
}
|