mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 12:14:40 +00:00
fix(channels): annotate DM messages with sender identity (#120)
* fix(channels): annotate DM messages with sender identity
Telegram and Zalo group messages already include [From: sender] prefix
so the agent knows who is talking, but DM messages were sent without
any sender context — the agent had no way to address the user by name.
- Telegram DM: add [From: @username] (or FirstName if no username)
- Zalo DM: add [From: displayName] when dName is present in payload
* fix(tests): add missing EnsureUserProfile to test stubs
AgentStore interface gained EnsureUserProfile in 4fce731 but the test
stub implementations were not updated, breaking CI on main.
---------
Co-authored-by: Luvu182 <208665161+Luvu182@users.noreply.github.com>
This commit is contained in:
1 parent
39b0104a7c
commit
a4f2d02a80
5 files changed
+19
No files matched your search
@@ -108,6 +108,9 @@ func (s *seedStubStore) ListUserInstances(_ context.Context, _ uuid.UUID) ([]sto
|
||||
func (s *seedStubStore) UpdateUserProfileMetadata(_ context.Context, _ uuid.UUID, _ string, _ map[string]string) error {
|
||||
return nil
|
||||
}
|
||||
func (s *seedStubStore) EnsureUserProfile(_ context.Context, _ uuid.UUID, _ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ---- Tests ----
|
||||
|
||||
|
||||
@@ -358,6 +358,9 @@ func (c *Channel) handleMessage(ctx context.Context, update telego.Update) {
|
||||
} else {
|
||||
finalContent = annotated
|
||||
}
|
||||
} else {
|
||||
// DM: annotate with sender identity so the agent knows who is messaging.
|
||||
finalContent = fmt.Sprintf("[From: %s]\n%s", senderLabel, content)
|
||||
}
|
||||
|
||||
// Send typing indicator with keepalive + TTL safety net.
|
||||
|
||||
@@ -43,8 +43,15 @@ func (c *Channel) handleDM(msg protocol.UserMessage) {
|
||||
return
|
||||
}
|
||||
|
||||
// Annotate with sender display name so the agent knows who is messaging.
|
||||
senderName := msg.Data.DName
|
||||
if senderName != "" {
|
||||
content = fmt.Sprintf("[From: %s]\n%s", senderName, content)
|
||||
}
|
||||
|
||||
slog.Debug("zalo_personal DM received",
|
||||
"sender", senderID,
|
||||
"dname", senderName,
|
||||
"thread", threadID,
|
||||
"preview", channels.Truncate(content, 50),
|
||||
)
|
||||
|
||||
@@ -101,6 +101,9 @@ func (s *createCaptureStore) ListUserInstances(_ context.Context, _ uuid.UUID) (
|
||||
func (s *createCaptureStore) UpdateUserProfileMetadata(_ context.Context, _ uuid.UUID, _ string, _ map[string]string) error {
|
||||
return nil
|
||||
}
|
||||
func (s *createCaptureStore) EnsureUserProfile(_ context.Context, _ uuid.UUID, _ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ---- helpers ----
|
||||
|
||||
|
||||
@@ -90,6 +90,9 @@ func (s *stubAgentStore) ListUserInstances(_ context.Context, _ uuid.UUID) ([]st
|
||||
func (s *stubAgentStore) UpdateUserProfileMetadata(_ context.Context, _ uuid.UUID, _ string, _ map[string]string) error {
|
||||
return nil
|
||||
}
|
||||
func (s *stubAgentStore) EnsureUserProfile(_ context.Context, _ uuid.UUID, _ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ---- Tests ----
|
||||
|
||||
|
||||
Reference in new issue
Block a user