mirror of
https://github.com/block/buzz.git
synced 2026-11-03 07:51:22 +00:00
Limit DM auto-routing to one agent participant
This commit is contained in:
@@ -81,6 +81,18 @@ test("DM composer auto-routes only when exactly one other participant is an agen
|
||||
[],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
getDmAutoRouteAgentPubkeys({
|
||||
channel: channel({
|
||||
channelType: "dm",
|
||||
participantPubkeys: ["human", "agent-one", "human-two"],
|
||||
}),
|
||||
currentPubkey: "human",
|
||||
knownAgentPubkeys,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
getDmAutoRouteAgentPubkeys({
|
||||
channel: channel({
|
||||
|
||||
@@ -111,14 +111,21 @@ export function getDmAutoRouteAgentPubkeys({
|
||||
? normalizePubkey(currentPubkey)
|
||||
: null;
|
||||
|
||||
return singleKnownAgentPubkey(
|
||||
channel.participantPubkeys.filter(
|
||||
(pubkey) =>
|
||||
!normalizedCurrentPubkey ||
|
||||
normalizePubkey(pubkey) !== normalizedCurrentPubkey,
|
||||
),
|
||||
knownAgentPubkeys,
|
||||
);
|
||||
const otherParticipants = new Map<string, string>();
|
||||
for (const pubkey of channel.participantPubkeys) {
|
||||
const normalized = normalizePubkey(pubkey);
|
||||
if (!normalized || normalized === normalizedCurrentPubkey) {
|
||||
continue;
|
||||
}
|
||||
|
||||
otherParticipants.set(normalized, pubkey);
|
||||
}
|
||||
|
||||
if (otherParticipants.size !== 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return singleKnownAgentPubkey(otherParticipants.values(), knownAgentPubkeys);
|
||||
}
|
||||
|
||||
export function getThreadAutoRouteAgentPubkeys({
|
||||
|
||||
Reference in New Issue
Block a user