v0.7.10 - Fixed api errors in accepting : in subscriptions
This commit is contained in:
12
api/index.js
12
api/index.js
@@ -728,9 +728,15 @@
|
||||
|
||||
|
||||
|
||||
// Generate random subscription ID
|
||||
// Generate random subscription ID (avoiding colons which are rejected by relay)
|
||||
function generateSubId() {
|
||||
return Math.random().toString(36).substring(2, 15);
|
||||
// Use only alphanumeric characters, underscores, and hyphens
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
|
||||
let result = '';
|
||||
for (let i = 0; i < 12; i++) {
|
||||
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Configuration subscription using nostr-tools SimplePool
|
||||
@@ -766,7 +772,7 @@
|
||||
console.log(`User pubkey ${userPubkey}`)
|
||||
// Subscribe to kind 23457 events (admin response events), kind 4 (NIP-04 DMs), and kind 1059 (NIP-17 GiftWrap)
|
||||
const subscription = relayPool.subscribeMany([url], [{
|
||||
since: Math.floor(Date.now() / 1000),
|
||||
since: Math.floor(Date.now() / 1000) - 5, // Look back 5 seconds to avoid race condition
|
||||
kinds: [23457],
|
||||
authors: [getRelayPubkey()], // Only listen to responses from the relay
|
||||
"#p": [userPubkey], // Only responses directed to this user
|
||||
|
||||
Reference in New Issue
Block a user