v1.2.55 - Preserve relay version metadata for API header/title and accept JSON NIP-11 content type
This commit is contained in:
+15
-13
@@ -194,9 +194,9 @@ async function fetchRelayInfo(relayUrl) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (!contentType || !contentType.includes('application/nostr+json')) {
|
||||
throw new Error(`Invalid content type: ${contentType}. Expected application/nostr+json`);
|
||||
const contentType = response.headers.get('content-type') || '';
|
||||
if (!contentType.includes('application/nostr+json') && !contentType.includes('application/json')) {
|
||||
log(`Unexpected NIP-11 content type: ${contentType}; attempting JSON parse anyway`, 'WARN');
|
||||
}
|
||||
|
||||
const relayInfo = await response.json();
|
||||
@@ -448,18 +448,20 @@ async function setupAutomaticRelayConnection(showSections = false) {
|
||||
const httpUrl = relayUrl.replace('ws', 'http').replace('wss', 'https');
|
||||
const relayInfo = await fetchRelayInfo(httpUrl);
|
||||
|
||||
if (relayInfo && relayInfo.pubkey) {
|
||||
relayPubkey = relayInfo.pubkey;
|
||||
relayInfoData = {
|
||||
name: relayInfo.name || 'C-Relay',
|
||||
version: relayInfo.version || '',
|
||||
description: relayInfo.description || 'Nostr Relay',
|
||||
pubkey: relayPubkey
|
||||
};
|
||||
const fetchedPubkey = relayInfo && relayInfo.pubkey ? relayInfo.pubkey : null;
|
||||
relayPubkey = fetchedPubkey || '4f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa';
|
||||
|
||||
// Keep relay metadata (including version) even when pubkey is missing/fallback
|
||||
relayInfoData = {
|
||||
name: relayInfo?.name || 'C-Relay',
|
||||
version: relayInfo?.version || '',
|
||||
description: relayInfo?.description || 'Nostr Relay',
|
||||
pubkey: relayPubkey
|
||||
};
|
||||
|
||||
if (fetchedPubkey) {
|
||||
console.log('🔑 Auto-fetched relay pubkey:', relayPubkey.substring(0, 16) + '...');
|
||||
} else {
|
||||
// Use fallback pubkey
|
||||
relayPubkey = '4f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa';
|
||||
console.log('⚠️ Using fallback relay pubkey');
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
+2
-2
@@ -13,8 +13,8 @@
|
||||
// Using CRELAY_ prefix to avoid conflicts with nostr_core_lib VERSION macros
|
||||
#define CRELAY_VERSION_MAJOR 1
|
||||
#define CRELAY_VERSION_MINOR 2
|
||||
#define CRELAY_VERSION_PATCH 54
|
||||
#define CRELAY_VERSION "v1.2.54"
|
||||
#define CRELAY_VERSION_PATCH 55
|
||||
#define CRELAY_VERSION "v1.2.55"
|
||||
|
||||
// Relay metadata (authoritative source for NIP-11 information)
|
||||
#define RELAY_NAME "C-Relay"
|
||||
|
||||
Reference in New Issue
Block a user