mirror of
https://github.com/block/buzz.git
synced 2026-11-03 07:51:22 +00:00
Fix task conversation auto routing
This commit is contained in:
@@ -70,10 +70,20 @@ test("continued conversation auto-routes only a single messageable agent", () =>
|
||||
["agent-one"],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
getAutoRoutedAgentConversationPubkeys([
|
||||
{ canMessage: true, pubkey: "agent-one" },
|
||||
{ canMessage: false, pubkey: "agent-two" },
|
||||
{ canMessage: false, pubkey: "agent-three" },
|
||||
]),
|
||||
["agent-one"],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
getAutoRoutedAgentConversationPubkeys([
|
||||
{ canMessage: true, pubkey: "agent-one" },
|
||||
{ canMessage: true, pubkey: "agent-two" },
|
||||
{ canMessage: false, pubkey: "agent-three" },
|
||||
]),
|
||||
[],
|
||||
);
|
||||
|
||||
@@ -110,12 +110,15 @@ export function agentConversationsStorageKey(
|
||||
export function getAutoRoutedAgentConversationPubkeys(
|
||||
participants: readonly AgentConversationRouteableParticipant[],
|
||||
): string[] {
|
||||
if (participants.length !== 1) {
|
||||
const messageableParticipants = participants.filter(
|
||||
(participant) => participant.canMessage,
|
||||
);
|
||||
|
||||
if (messageableParticipants.length !== 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const [participant] = participants;
|
||||
return participant.canMessage ? [participant.pubkey] : [];
|
||||
return [messageableParticipants[0].pubkey];
|
||||
}
|
||||
|
||||
export function buildAgentConversationMentionPubkeys({
|
||||
|
||||
Reference in New Issue
Block a user