feat: send-proactive 消息记入平台日志 — ethend可见
This commit is contained in:
@@ -18,6 +18,7 @@ type BridgeHandler struct {
|
||||
internalToken string
|
||||
channelsMu sync.RWMutex
|
||||
cachedChannels []bridge.ChannelInfo
|
||||
logFn func(platform, channelID, senderID, content string, success bool) // outgoing message logger
|
||||
}
|
||||
|
||||
func NewBridgeHandler(router *bridge.PlatformRouter) *BridgeHandler {
|
||||
@@ -27,6 +28,11 @@ func NewBridgeHandler(router *bridge.PlatformRouter) *BridgeHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// SetLogFunc sets the outgoing message logger callback.
|
||||
func (h *BridgeHandler) SetLogFunc(fn func(platform, channelID, senderID, content string, success bool)) {
|
||||
h.logFn = fn
|
||||
}
|
||||
|
||||
func (h *BridgeHandler) RegisterRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("/health", h.health)
|
||||
mux.HandleFunc("/api/v1/platforms", h.listPlatforms)
|
||||
@@ -220,6 +226,13 @@ func (h *BridgeHandler) sendProactive(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
log.Printf("[send-proactive] 已发送: adapter=%s chat=%s user=%d group=%d at=%s len=%d",
|
||||
adapterName, msgType, userID, groupID, req.AtUserID, len(content))
|
||||
if h.logFn != nil {
|
||||
chID := req.GroupID
|
||||
if msgType == "private" {
|
||||
chID = req.UserID
|
||||
}
|
||||
h.logFn(req.Platform, chID, "Cyrene", content, true)
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]interface{}{
|
||||
"success": true,
|
||||
"message": "消息已发送",
|
||||
|
||||
Reference in New Issue
Block a user