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

Function eventToProject

desktop/src/features/projects/hooks.ts:164–196  ·  view source on GitHub ↗
(event: RelayEvent)

Source from the content-addressed store, hash-verified

162}
163
164function eventToProject(event: RelayEvent): Project {
165 const d = getTag(event, "d") ?? event.id;
166 const name = getTag(event, "name") || d;
167 const description = getTag(event, "description") || event.content || "";
168 const cloneUrls = getCloneUrls(event);
169 const webUrl = getTag(event, "web") ?? null;
170 const setupUsers = getAllTags(event, "auth");
171 const contributors = [...new Set([...getAllTags(event, "p"), ...setupUsers])];
172 // `h`/`project-channel`, `status`, and `default-branch` are NOT part of
173 // NIP-34 — they are read-side tolerance for extension tags no code writes
174 // today (the write path that emitted them was removed). If a write path is
175 // reintroduced it must go through the buzz-sdk repo-announcement builder;
176 // the canonical NIP-34 source for the default branch is the kind:30618
177 // state event's HEAD ref, not a 30617 tag.
178 const projectChannelId =
179 getTag(event, "h") ?? getTag(event, "project-channel") ?? null;
180
181 return {
182 id: `${event.pubkey}:${d}`,
183 dtag: d,
184 name,
185 description,
186 cloneUrls,
187 webUrl,
188 owner: event.pubkey,
189 contributors,
190 createdAt: event.created_at,
191 projectChannelId,
192 status: getTag(event, "status") ?? "active",
193 defaultBranch: getTag(event, "default-branch") ?? "main",
194 repoAddress: projectCoordinate({ owner: event.pubkey, dtag: d }),
195 };
196}
197
198function dedup(events: RelayEvent[]): RelayEvent[] {
199 const best = new Map<string, RelayEvent>();

Callers 1

fetchProjectFunction · 0.85

Calls 4

projectCoordinateFunction · 0.85
getTagFunction · 0.70
getCloneUrlsFunction · 0.70
getAllTagsFunction · 0.70

Tested by

no test coverage detected