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

Function handleGetChannelMembers

desktop/src/testing/e2eBridge.ts:5182–5215  ·  view source on GitHub ↗
(
  args: { channelId: string },
  config: E2eConfig | undefined,
)

Source from the content-addressed store, hash-verified

5180}
5181
5182async function handleGetChannelMembers(
5183 args: { channelId: string },
5184 config: E2eConfig | undefined,
5185): Promise<RawChannelMembersResponse> {
5186 const identity = getIdentity(config);
5187 if (!identity) {
5188 const channel = getMockChannel(args.channelId);
5189 return {
5190 members: cloneMembers(channel.members),
5191 next_cursor: null,
5192 };
5193 }
5194
5195 const memberEvents = await relayQuery(config, [
5196 { kinds: [39002], "#d": [args.channelId], limit: 1 },
5197 ]);
5198 const memberTags = ((memberEvents[0]?.tags ?? []) as string[][]).filter(
5199 (t) => t[0] === "p",
5200 );
5201 const members = memberTags.map((t) => ({
5202 pubkey: t[1],
5203 role: (t[3] ?? t[2] ?? "member") as
5204 | "owner"
5205 | "admin"
5206 | "member"
5207 | "guest"
5208 | "bot",
5209 is_agent: (t[3] ?? t[2]) === "bot",
5210 display_name: null,
5211 avatar_url: null,
5212 joined_at: new Date().toISOString(),
5213 }));
5214 return { members, next_cursor: null };
5215}
5216
5217async function handleUpdateChannel(
5218 args: {

Callers 1

handleMockCommandFunction · 0.85

Calls 4

getMockChannelFunction · 0.85
cloneMembersFunction · 0.85
relayQueryFunction · 0.85
getIdentityFunction · 0.70

Tested by

no test coverage detected