MCPcopy Create free account
hub / github.com/block/buzz / handleAddChannelMembers

Function handleAddChannelMembers

desktop/src/testing/e2eBridge.ts:5479–5548  ·  view source on GitHub ↗
(
  args: {
    channelId: string;
    pubkeys: string[];
    role?: RawChannelMember["role"];
  },
  config: E2eConfig | undefined,
)

Source from the content-addressed store, hash-verified

5477}
5478
5479async function handleAddChannelMembers(
5480 args: {
5481 channelId: string;
5482 pubkeys: string[];
5483 role?: RawChannelMember["role"];
5484 },
5485 config: E2eConfig | undefined,
5486): Promise<RawAddChannelMembersResponse> {
5487 const addChannelMembersDelayMs = config?.mock?.addChannelMembersDelayMs ?? 0;
5488 if (addChannelMembersDelayMs > 0) {
5489 await new Promise((resolve) =>
5490 window.setTimeout(resolve, addChannelMembersDelayMs),
5491 );
5492 }
5493 const identity = getIdentity(config);
5494 if (!identity) {
5495 const channel = getMockChannel(args.channelId);
5496 const added: string[] = [];
5497 const errors: RawAddChannelMembersResponse["errors"] = [];
5498
5499 for (const pubkey of args.pubkeys) {
5500 if (channel.members.some((member) => member.pubkey === pubkey)) {
5501 errors.push({
5502 pubkey,
5503 error: "Already a member.",
5504 });
5505 continue;
5506 }
5507
5508 channel.members.push({
5509 pubkey,
5510 role: args.role ?? "member",
5511 is_agent:
5512 args.role === "bot" ||
5513 mockAgentPubkeys.has(pubkey) ||
5514 mockManagedAgents.some((agent) => agent.pubkey === pubkey),
5515 joined_at: new Date().toISOString(),
5516 display_name: mockDisplayNames.get(pubkey) ?? null,
5517 });
5518 added.push(pubkey);
5519 }
5520
5521 syncMockChannel(channel);
5522 touchMockChannel(channel);
5523 syncMockRelayAgentsFromManagedAgents();
5524 return {
5525 added,
5526 errors,
5527 };
5528 }
5529
5530 const added: string[] = [];
5531 const errors: RawAddChannelMembersResponse["errors"] = [];
5532 for (const pubkey of args.pubkeys) {
5533 try {
5534 const tags: string[][] = [
5535 ["h", args.channelId],
5536 ["p", pubkey],

Callers 1

handleMockCommandFunction · 0.85

Calls 9

getMockChannelFunction · 0.85
syncMockChannelFunction · 0.85
touchMockChannelFunction · 0.85
submitSignedEventFunction · 0.85
pushMethod · 0.80
hasMethod · 0.80
getIdentityFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected