Update existing repo announcements with current GRASP servers

- When an existing NIP-34 repository announcement is found, extract all metadata (name, description, web URLs, t-tags, earliest commit)
- Update the announcement with current GRASP server clone URLs and relays from config
- Publish the updated event to keep repository announcements in sync with GRASP configuration
- Remove invalid onProjectDeleted prop from ProjectDetailsDialog usage (prop was removed in previous refactor)
This commit is contained in:
Alex Gleason committed 2025-12-23 07:31:33 -06:00
1 parent 8174db459f
commit f7fc018ae2
2 files changed
+53 -7

No files matched your search

@@ -60,12 +60,60 @@ export function ConfigureRepoStep({
let repoEvent: NostrEvent;
if (existingRepos.length > 0) {
// Use existing repo announcement
repoEvent = existingRepos[0];
// Use existing repo announcement as template and update with current GRASP servers
const existingEvent = existingRepos[0];
// Republish the event
// TODO: use this event as a template, and "fix" it, signing and publishing a new event
await nostr.event(repoEvent);
// Convert user's GRASP servers to clone URLs and relay URLs
const npub = nip19.npubEncode(user.pubkey);
const cloneUrls = new Set<string>();
const relays = new Set<string>();
for (const graspRelay of config.graspMetadata.relays) {
try {
const relayUrl = new URL(graspRelay.url);
relays.add(relayUrl.href);
const cloneUrl = new URL(`/${npub}/${projectId}.git`, `https://${relayUrl.host}`);
cloneUrls.add(cloneUrl.href);
} catch (err) {
console.warn(`Failed to parse Nostr git relay URL: ${graspRelay.url}`, err);
}
}
// Validate that we have at least one clone URL and relay
if (cloneUrls.size === 0 || relays.size === 0) {
throw new Error('No Nostr git servers configured. Please configure Nostr git servers in Settings > Nostr.');
}
// Extract existing data from the event
const name = existingEvent.tags.find(([tagName]) => tagName === 'name')?.[1];
const description = existingEvent.tags.find(([tagName]) => tagName === 'description')?.[1];
const webTag = existingEvent.tags.find(([tagName]) => tagName === 'web');
const webUrls = webTag ? webTag.slice(1) : undefined;
const tTags = existingEvent.tags
.filter(([tagName]) => tagName === 't')
.map(([, value]) => value);
const eucTag = existingEvent.tags.find(([tagName, , marker]) => tagName === 'r' && marker === 'euc');
const earliestCommit = eucTag?.[1];
// Create updated repository announcement event with new clone URLs and relays
const eventTemplate = createRepositoryAnnouncementEvent({
repoId: projectId,
name,
description,
webUrls,
cloneUrls: [...cloneUrls],
relays: [...relays],
tTags: tTags.length > 0 ? tTags : undefined,
earliestCommit,
});
// Publish the updated event
repoEvent = await publishEvent(eventTemplate);
// Wait 5 seconds for Nostr git servers to update
await new Promise(resolve => setTimeout(resolve, 5000));
} else {
// Create and publish new NIP-34 repository announcement
-2
View File
@@ -443,7 +443,6 @@ export function ProjectView() {
project={project}
open={isProjectDetailsOpen}
onOpenChange={setIsProjectDetailsOpen}
onProjectDeleted={handleProjectDeleted}
/>
<GitHistoryDialog
projectId={project.id}
@@ -649,7 +648,6 @@ export function ProjectView() {
project={project}
open={isProjectDetailsOpen}
onOpenChange={setIsProjectDetailsOpen}
onProjectDeleted={handleProjectDeleted}
/>
<GitHistoryDialog
projectId={project.id}