fix(gatewayrpc): sender_id and rate_limited cross the chat wire

This commit is contained in:
sam committed 2026-10-04 17:18:38 +11:00
1 parent 5b3441c553
commit 7efc96bf70
6 files changed
+61 -11

No files matched your search

+1 -1
View File
@@ -63,7 +63,7 @@ func (c *Client) Route(ctx context.Context, in messaging.Inbound) (messaging.Cha
if err != nil {
return messaging.ChatReply{}, err
}
return messaging.ChatReply{Text: v.Text, SessionID: v.SessionId}, nil
return messaging.ChatReply{Text: v.Text, SessionID: v.SessionId, RateLimited: v.RateLimited}, nil
}
func (c *Client) Cancel(ctx context.Context, id string) (messaging.ChatCancellation, error) {
+1 -1
View File
@@ -72,7 +72,7 @@ func (s *server) Route(ctx context.Context, r *pb.RouteRequest) (*pb.RouteRespon
if err != nil {
return nil, err
}
return &pb.RouteResponse{Text: v.Text, SessionId: v.SessionID}, nil
return &pb.RouteResponse{Text: v.Text, SessionId: v.SessionID, RateLimited: v.RateLimited}, nil
}
func (s *server) Cancel(ctx context.Context, r *pb.CancelRequest) (*pb.CancelResponse, error) {
@@ -33,6 +33,7 @@ func storedProto(m messaging.Message) *pb.Message {
ChannelId: m.ConversationID.ChannelID,
ThreadId: m.ConversationID.ThreadID,
From: m.Sender,
SenderId: m.SenderID,
Text: m.Text,
At: timestamp(m.At),
Media: attachmentProtoList(m.Media),
@@ -50,6 +51,7 @@ func storedValue(v *pb.Message) messaging.Message {
SourceID: v.SourceId,
ConversationID: messaging.ConversationID{ChannelID: v.ChannelId, ThreadID: v.ThreadId},
Sender: v.From,
SenderID: v.SenderId,
Text: v.Text,
At: timeValue(v.At),
Media: attachmentValueList(v.GetMedia()),
@@ -0,0 +1,17 @@
package gatewayrpc
import (
"testing"
"github.com/samcharles93/archie-core/internal/domain/messaging"
)
// TestChatWireKeepsGatewayInputs pins the fields the Gateway decides on
// across the messaging-to-gateway hop.
func TestChatWireKeepsGatewayInputs(t *testing.T) {
in := messaging.Inbound{Message: messaging.Message{SenderID: "42"}, BudgetKey: "/hooks/a", Platform: "telegram"}
got := inboundValue(inboundProto(in))
if got.Message.SenderID != "42" || got.BudgetKey != "/hooks/a" || got.Platform != "telegram" {
t.Fatalf("inbound round trip lost a field: %+v", got)
}
}