create daemon

This commit is contained in:
Your Name
2025-09-29 07:21:46 -04:00
parent 955090b079
commit 69514943a9
1341 changed files with 181418 additions and 0 deletions

View File

@@ -343,6 +343,7 @@
privacyPolicy: '',
termsOfService: '',
refreshRate: 60, // default 60 seconds
maxDelay: 86460, // default 1 day + 60 seconds maximum delay
content: event.content || ''
};
@@ -386,6 +387,9 @@
case 'refresh_rate':
thrower.refreshRate = parseInt(tag[1]) || 60;
break;
case 'max_delay':
thrower.maxDelay = parseInt(tag[1]) || 86460;
break;
}
}
});
@@ -571,6 +575,10 @@
<span><strong>Refresh Rate:</strong></span>
<span>${thrower.refreshRate}s</span>
</div>
<div class="thrower-detail">
<span><strong>Max Delay:</strong></span>
<span>${thrower.maxDelay}s</span>
</div>
<div class="thrower-detail">
<span><strong>Last Update:</strong></span>
<span>${lastSeen}</span>
@@ -816,6 +824,8 @@
// Clear relay dropdown until manual input is provided
clearRelayDropdown(bounceId);
// Reset delay constraints for manual input
updateDelayConstraints(bounceId, null);
} else if (select.value) {
// Hide manual input and use selected thrower
manualDiv.classList.add('hidden');
@@ -824,11 +834,15 @@
// Populate relay dropdown based on selected thrower
populateRelayDropdown(bounceId, select.value);
// Update delay constraints based on selected thrower
updateDelayConstraints(bounceId, select.value);
} else {
// No selection - hide manual input and clear relay dropdown
manualDiv.classList.add('hidden');
input.value = '';
clearRelayDropdown(bounceId);
// Reset delay constraints
updateDelayConstraints(bounceId, null);
}
// Check if bounce inputs are valid and update button state
@@ -882,6 +896,7 @@
pubkey = window.NostrTools.nip19.decode(pubkey).data;
} catch (error) {
clearRelayDropdown(bounceId);
updateDelayConstraints(bounceId, null);
return;
}
}
@@ -889,11 +904,14 @@
// Find thrower in discovered list and populate relays
if (pubkey && /^[0-9a-fA-F]{64}$/.test(pubkey)) {
populateRelayDropdown(bounceId, pubkey);
updateDelayConstraints(bounceId, pubkey);
} else {
clearRelayDropdown(bounceId);
updateDelayConstraints(bounceId, null);
}
} else {
clearRelayDropdown(bounceId);
updateDelayConstraints(bounceId, null);
}
// Update button state after thrower input change
@@ -1099,6 +1117,41 @@
return relayUrls.join(', ');
}
// Update delay input constraints based on selected thrower's maximum delay
function updateDelayConstraints(bounceId, throwerPubkey) {
const delayInput = document.getElementById(`delay-${bounceId}`);
if (!delayInput) return;
if (!throwerPubkey) {
// No thrower selected - reset to default constraints
delayInput.max = '';
delayInput.title = 'Enter delay in seconds (minimum 1 second)';
console.log('INFO', `Reset delay constraints for bounce ${bounceId} - no thrower selected`);
return;
}
// Find the thrower and get its maximum delay
const thrower = discoveredThrowers.find(t => t.pubkey === throwerPubkey);
if (thrower && thrower.maxDelay) {
delayInput.max = thrower.maxDelay;
delayInput.title = `Enter delay in seconds (minimum 1, maximum ${thrower.maxDelay} for this thrower)`;
// If current value exceeds max, reset to max
const currentValue = parseInt(delayInput.value);
if (currentValue > thrower.maxDelay) {
delayInput.value = thrower.maxDelay;
console.log('INFO', `Reduced delay from ${currentValue}s to ${thrower.maxDelay}s (thrower maximum) for bounce ${bounceId}`);
}
console.log('INFO', `Set maximum delay constraint to ${thrower.maxDelay}s for bounce ${bounceId} (thrower: ${thrower.name})`);
} else {
// Thrower found but no max delay info - reset constraints
delayInput.max = '';
delayInput.title = 'Enter delay in seconds (minimum 1 second) - thrower maximum delay unknown';
console.log('INFO', `No maximum delay info available for bounce ${bounceId} thrower`);
}
}
// Decrypt and display bounce content for testing
function decryptBounce(bounceId) {
try {
@@ -1308,6 +1361,13 @@
return;
}
// Validate delay against thrower's maximum delay
const thrower = discoveredThrowers.find(t => t.pubkey === throwerPubkey);
if (thrower && thrower.maxDelay && delay > thrower.maxDelay) {
alert(`Delay of ${delay}s exceeds this thrower's maximum delay of ${thrower.maxDelay}s. Please reduce the delay.`);
return;
}
try {
// Determine what event to wrap
let eventToWrap;