Browse Source

bug-fix

master
Silberengel 1 month ago
parent
commit
07f7af33b8
  1. 4
      public/healthz.json
  2. 15
      src/lib/modules/comments/CommentForm.svelte
  3. 36
      src/lib/services/nostr/nostr-client.ts

4
public/healthz.json

@ -2,7 +2,7 @@
"status": "ok", "status": "ok",
"service": "aitherboard", "service": "aitherboard",
"version": "0.1.1", "version": "0.1.1",
"buildTime": "2026-02-05T22:42:01.031Z", "buildTime": "2026-02-05T23:07:17.455Z",
"gitCommit": "unknown", "gitCommit": "unknown",
"timestamp": 1770331321031 "timestamp": 1770332837455
} }

15
src/lib/modules/comments/CommentForm.svelte

@ -168,18 +168,12 @@
} }
} }
// Extract mentions and add p tags
const mentions = await extractMentions(contentWithUrls);
const mentionPubkeys = getMentionPubkeys(mentions);
for (const pubkey of mentionPubkeys) {
tags.push(['p', pubkey]);
}
if (shouldIncludeClientTag()) { if (shouldIncludeClientTag()) {
tags.push(['client', 'aitherboard']); tags.push(['client', 'aitherboard']);
} }
// Add file attachments as imeta tags (like jumble) // Add file attachments as imeta tags (like jumble)
// Start with content and add file URLs
let contentWithUrls = content.trim(); let contentWithUrls = content.trim();
for (const file of uploadedFiles) { for (const file of uploadedFiles) {
// Use imeta tag from upload response (like jumble) // Use imeta tag from upload response (like jumble)
@ -197,6 +191,13 @@
contentWithUrls += `${file.url}\n`; contentWithUrls += `${file.url}\n`;
} }
} }
// Extract mentions and add p tags (after file URLs are added)
const mentions = await extractMentions(contentWithUrls);
const mentionPubkeys = getMentionPubkeys(mentions);
for (const pubkey of mentionPubkeys) {
tags.push(['p', pubkey]);
}
console.log(`[CommentForm] Final tags before publishing:`, tags); console.log(`[CommentForm] Final tags before publishing:`, tags);

36
src/lib/services/nostr/nostr-client.ts

@ -432,20 +432,16 @@ class NostrClient {
const db = await getDB(); const db = await getDB();
const tx = db.transaction('events', 'readonly'); const tx = db.transaction('events', 'readonly');
const index = tx.store.index('kind'); const index = tx.store.index('kind');
const events: NostrEvent[] = [];
let count = 0;
const targetLimit = Math.min(limit, maxEvents); const targetLimit = Math.min(limit, maxEvents);
// Use cursor to paginate through events // Use getAll() to get all matching events in one operation
let cursor = await index.openCursor(IDBKeyRange.only(kind), 'prev'); // This keeps the transaction active and avoids cursor iteration issues
while (cursor && count < targetLimit) { const allEvents = await index.getAll(kind);
events.push(cursor.value as NostrEvent);
count++;
cursor = await cursor.continue();
}
await tx.done; await tx.done;
return events;
// Sort by created_at (newest first) and limit
const sorted = allEvents.sort((a, b) => b.created_at - a.created_at);
return sorted.slice(0, targetLimit);
} catch (error) { } catch (error) {
console.debug('Error getting events by kind from cache:', error); console.debug('Error getting events by kind from cache:', error);
return []; return [];
@ -460,20 +456,16 @@ class NostrClient {
const db = await getDB(); const db = await getDB();
const tx = db.transaction('events', 'readonly'); const tx = db.transaction('events', 'readonly');
const index = tx.store.index('pubkey'); const index = tx.store.index('pubkey');
const events: NostrEvent[] = [];
let count = 0;
const targetLimit = Math.min(limit, maxEvents); const targetLimit = Math.min(limit, maxEvents);
// Use cursor to paginate through events // Use getAll() to get all matching events in one operation
let cursor = await index.openCursor(IDBKeyRange.only(pubkey), 'prev'); // This keeps the transaction active and avoids cursor iteration issues
while (cursor && count < targetLimit) { const allEvents = await index.getAll(pubkey);
events.push(cursor.value as NostrEvent);
count++;
cursor = await cursor.continue();
}
await tx.done; await tx.done;
return events;
// Sort by created_at (newest first) and limit
const sorted = allEvents.sort((a, b) => b.created_at - a.created_at);
return sorted.slice(0, targetLimit);
} catch (error) { } catch (error) {
console.debug('Error getting events by pubkey from cache:', error); console.debug('Error getting events by pubkey from cache:', error);
return []; return [];

Loading…
Cancel
Save