refactor(manager): update SendMessageWithID to accept bus.OutboundMessage

This commit is contained in:
Dmitrii Balabanov 2026-03-07 23:31:21 +02:00
parent eeabdd098f
commit e938241c0d
2 changed files with 9 additions and 12 deletions

View file

@ -411,7 +411,11 @@ func (al *AgentLoop) bindAdvancedMessageManagers(cm *channels.Manager) {
advancedManager.SetCallbacks(
// sendPlaceholder
func(channelName, chatID, content string) (string, error) {
return cm.SendMessageWithID(context.Background(), channelName, chatID, content)
return cm.SendMessageWithID(context.Background(), bus.OutboundMessage{
Channel: channelName,
ChatID: chatID,
Content: content,
})
},
// editMessage
func(channelName, chatID, messageID, content string) error {

View file

@ -837,16 +837,10 @@ func (m *Manager) SendToChannel(ctx context.Context, channelName, chatID, conten
// SendMessageWithID sends a message synchronously via the channel's native API if supported,
// returning the platform-specific message ID. If the channel does not support SyncSender,
// it falls back to the async bus and returns an error.
func (m *Manager) SendMessageWithID(ctx context.Context, channelName, chatID, content string) (string, error) {
ch, ok := m.GetChannel(channelName)
func (m *Manager) SendMessageWithID(ctx context.Context, msg bus.OutboundMessage) (string, error) {
ch, ok := m.GetChannel(msg.Channel)
if !ok {
return "", fmt.Errorf("channel %s not found", channelName)
}
msg := bus.OutboundMessage{
Channel: channelName,
ChatID: chatID,
Content: content,
return "", fmt.Errorf("channel %s not found", msg.Channel)
}
if syncSender, ok := ch.(SyncSender); ok {
@ -855,8 +849,7 @@ func (m *Manager) SendMessageWithID(ctx context.Context, channelName, chatID, co
return msgID, nil
}
logger.ErrorCF("manager", "SendMessageWithID failed", map[string]any{"error": err, "msgID": msgID})
} else {
logger.WarnCF("manager", "channel does not implement SyncSender", map[string]any{"channel": channelName})
logger.WarnCF("manager", "channel does not implement SyncSender", map[string]any{"channel": msg.Channel})
}
logger.WarnCF("manager", "falling back to bus publish", nil)