diff --git a/pkg/channels/whatsapp/whatsapp.go b/pkg/channels/whatsapp/whatsapp.go index f37df9097..f0db7b992 100644 --- a/pkg/channels/whatsapp/whatsapp.go +++ b/pkg/channels/whatsapp/whatsapp.go @@ -280,5 +280,5 @@ func (c *WhatsAppChannel) tryHandleCommand( }) } - return res.Matched + return res.Handled } diff --git a/pkg/channels/whatsapp/whatsapp_command_test.go b/pkg/channels/whatsapp/whatsapp_command_test.go index b8aac18f0..55f7f35da 100644 --- a/pkg/channels/whatsapp/whatsapp_command_test.go +++ b/pkg/channels/whatsapp/whatsapp_command_test.go @@ -12,7 +12,7 @@ func TestTryHandleCommand_UsesDispatcher(t *testing.T) { called := false ch.dispatcher = commands.DispatchFunc(func(context.Context, commands.Request) commands.Result { called = true - return commands.Result{Matched: true} + return commands.Result{Matched: true, Handled: true} }) handled := ch.tryHandleCommand(context.Background(), "/help", "chat1", "user1", "mid1") diff --git a/pkg/channels/whatsapp_native/whatsapp_command_test.go b/pkg/channels/whatsapp_native/whatsapp_command_test.go index fbf85d5bc..32e4c672c 100644 --- a/pkg/channels/whatsapp_native/whatsapp_command_test.go +++ b/pkg/channels/whatsapp_native/whatsapp_command_test.go @@ -14,7 +14,7 @@ func TestTryHandleCommand_UsesDispatcher(t *testing.T) { called := false ch.dispatcher = commands.DispatchFunc(func(context.Context, commands.Request) commands.Result { called = true - return commands.Result{Matched: true} + return commands.Result{Matched: true, Handled: true} }) handled := ch.tryHandleCommand(context.Background(), "/help", "chat1", "user1", "mid1") diff --git a/pkg/channels/whatsapp_native/whatsapp_native.go b/pkg/channels/whatsapp_native/whatsapp_native.go index 5289d9dcb..a15a72aca 100644 --- a/pkg/channels/whatsapp_native/whatsapp_native.go +++ b/pkg/channels/whatsapp_native/whatsapp_native.go @@ -422,7 +422,7 @@ func (c *WhatsAppNativeChannel) tryHandleCommand( "error": res.Err.Error(), }) } - return res.Matched + return res.Handled } func (c *WhatsAppNativeChannel) Send(ctx context.Context, msg bus.OutboundMessage) error { diff --git a/pkg/commands/dispatcher.go b/pkg/commands/dispatcher.go index 4c419bb3b..c149e0f86 100644 --- a/pkg/commands/dispatcher.go +++ b/pkg/commands/dispatcher.go @@ -17,6 +17,7 @@ type Request struct { type Result struct { Matched bool + Handled bool Command string Err error } @@ -51,10 +52,10 @@ func (d *Dispatcher) Dispatch(ctx context.Context, req Request) Result { continue } if def.Handler == nil { - return Result{Matched: true, Command: def.Name} + return Result{Matched: true, Handled: false, Command: def.Name} } err := def.Handler(ctx, req) - return Result{Matched: true, Command: def.Name, Err: err} + return Result{Matched: true, Handled: true, Command: def.Name, Err: err} } return Result{Matched: false}