Refactor numeric constants to centralized module

- Introduce `js/constants.js` with semantic time constants (e.g., `ONE_MINUTE_MS`, `STANDARD_TIMEOUT_MS`) and feature-specific TTLs.
- Export `KIND_MUTE_LIST` from `js/nostrEventSchemas.js` to standardize NIP-51 mute list kind usage.
- Refactor `js/state/cache.js`, `js/nostr/cachePolicies.js`, `js/channelProfile.js`, and various services to use centralized constants instead of hardcoded magic numbers.
- Update `js/nostr/relayConstants.js` to derive values from the shared time constants.
- Replace duplicate definitions of timeouts and retry delays across the codebase.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-11 03:27:26 +00:00
1 parent 83d8023767
commit c47392aba6
17 files changed
+92 -47

No files matched your search

+4 -4
View File
@@ -6,7 +6,7 @@ import {
import { publishEventToRelays, assertAnyRelayAccepted } from "../nostrPublish.js";
import { accessControl } from "../accessControl.js";
import { userBlocks, USER_BLOCK_EVENTS } from "../userBlocks.js";
import { buildReportEvent } from "../nostrEventSchemas.js";
import { buildReportEvent, KIND_MUTE_LIST } from "../nostrEventSchemas.js";
import logger from "../utils/logger.js";
/**
@@ -1182,7 +1182,7 @@ export class ModerationService {
this.log(`[moderationService] Refreshing mute subscriptions for ${authors.length} authors in ${chunks.length} batches`);
for (const chunk of chunks) {
const filter = { kinds: [10000], authors: chunk };
const filter = { kinds: [KIND_MUTE_LIST], authors: chunk };
try {
const sub = this.nostrClient.pool.sub(relays, [filter]);
sub.on("event", (event) => {
@@ -1347,7 +1347,7 @@ export class ModerationService {
return;
}
if (!event || event.kind !== 10000) {
if (!event || event.kind !== KIND_MUTE_LIST) {
this.replaceTrustedMuteList(owner, new Set(), { createdAt: 0, eventId: "" });
return;
}
@@ -1387,7 +1387,7 @@ export class ModerationService {
}
ingestTrustedMuteEvent(event) {
if (!event || event.kind !== 10000) {
if (!event || event.kind !== KIND_MUTE_LIST) {
return;
}