From 5ca378bb96761feb7b34d9ef5e2f1dbd87348f51 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 04:05:36 +0000 Subject: [PATCH] Add ENABLE_NIP17_RELAY_WARNING config to suppress privacy warnings Added a new configuration variable `ENABLE_NIP17_RELAY_WARNING` to `config/instance-config.js` (defaulting to `false`) to control the display of NIP-17 relay fallback warnings. Updated `js/ui/profileModalController.js` and `js/app.js` to respect this setting. This change allows instance operators to disable "Privacy warning: direct messages are using your default relays because no NIP-17 relay list is available" and related notifications. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- config/instance-config.js | 12 ++++++++++++ js/app.js | 3 ++- js/config.js | 2 ++ js/ui/profileModalController.js | 21 ++++++++++++++++++--- tests/profile-modal-controller.test.mjs | 19 +++++++++++++++++++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/config/instance-config.js b/config/instance-config.js index 8f7313d9..14db743a 100644 --- a/config/instance-config.js +++ b/config/instance-config.js @@ -452,3 +452,15 @@ export const DEFAULT_PLAYBACK_SOURCE = "torrent"; * if the primary source is slow or stalled. */ export const DEFAULT_PLAYBACK_START_TIMEOUT = 3000; + +/** + * Whether to display privacy warnings when NIP-17 DM relay lists are missing. + * + * When set to `true`, the UI alerts users if their recipient has not published + * a NIP-17 relay list (falling back to default relays), or if DM delivery falls + * back to NIP-04/default relays due to missing configuration. + * + * Set to `false` to suppress these warnings for a cleaner UI, assuming users + * accept the privacy trade-offs of legacy routing. + */ +export const ENABLE_NIP17_RELAY_WARNING = false; diff --git a/js/app.js b/js/app.js index 513dc84d..79273a36 100644 --- a/js/app.js +++ b/js/app.js @@ -10,6 +10,7 @@ import { ADMIN_DM_IMAGE_URL, BITVID_WEBSITE_URL, ALLOW_NSFW_CONTENT, + ENABLE_NIP17_RELAY_WARNING, } from "./config.js"; import { accessControl } from "./accessControl.js"; import { extractBtihFromMagnet, safeDecodeMagnet } from "./magnetUtils.js"; @@ -3042,7 +3043,7 @@ class Application { ? recipient.relayHints : []; - if (enabled && !relayHints.length) { + if (ENABLE_NIP17_RELAY_WARNING && enabled && !relayHints.length) { this.showStatus( "Privacy warning: this recipient has not shared NIP-17 relays, so we'll use your default relays.", ); diff --git a/js/config.js b/js/config.js index d8c31343..4f9e6b98 100644 --- a/js/config.js +++ b/js/config.js @@ -43,6 +43,7 @@ import { ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS, DEFAULT_PLAYBACK_SOURCE, DEFAULT_PLAYBACK_START_TIMEOUT, + ENABLE_NIP17_RELAY_WARNING, } from "../config/instance-config.js"; export const WATCH_HISTORY_VERSION_TAG_VALUE = "2"; @@ -166,3 +167,4 @@ export { VIEW_COUNT_CACHE_TTL_MS }; export { ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS }; export { DEFAULT_PLAYBACK_SOURCE }; export { DEFAULT_PLAYBACK_START_TIMEOUT }; +export { ENABLE_NIP17_RELAY_WARNING }; diff --git a/js/ui/profileModalController.js b/js/ui/profileModalController.js index f3871dd1..24358627 100644 --- a/js/ui/profileModalController.js +++ b/js/ui/profileModalController.js @@ -4,6 +4,7 @@ import { ADMIN_DM_IMAGE_URL as CONFIG_ADMIN_DM_IMAGE_URL, BITVID_WEBSITE_URL as CONFIG_BITVID_WEBSITE_URL, MAX_WALLET_DEFAULT_ZAP as CONFIG_MAX_WALLET_DEFAULT_ZAP, + ENABLE_NIP17_RELAY_WARNING as CONFIG_ENABLE_NIP17_RELAY_WARNING, } from "../config.js"; import { normalizeDesignSystemContext } from "../designSystem.js"; import { RUNTIME_FLAGS } from "../constants.js"; @@ -155,10 +156,20 @@ export class ProfileModalController { return fromConfig || DEFAULT_BITVID_WEBSITE_URL; })(); + const resolvedEnableNip17RelayWarning = (() => { + if (typeof providedConstants.ENABLE_NIP17_RELAY_WARNING === "boolean") { + return providedConstants.ENABLE_NIP17_RELAY_WARNING; + } + return typeof CONFIG_ENABLE_NIP17_RELAY_WARNING === "boolean" + ? CONFIG_ENABLE_NIP17_RELAY_WARNING + : true; + })(); + this.maxWalletDefaultZap = resolvedMaxWalletDefaultZap; this.adminSuperNpub = resolvedAdminSuperNpub; this.adminDmImageUrl = resolvedAdminDmImageUrl; this.bitvidWebsiteUrl = resolvedbitvidWebsiteUrl; + this.enableNip17RelayWarning = resolvedEnableNip17RelayWarning; this.hasShownRelayWarning = false; this.internalState = { @@ -2233,7 +2244,7 @@ export class ProfileModalController { ? recipientContext.relayHints : []; - if (enabled && !relayHints.length) { + if (this.enableNip17RelayWarning && enabled && !relayHints.length) { this.showStatus( "Privacy warning: this recipient has not shared NIP-17 relays, so we'll use your default relays.", { autoHideMs: 5000 }, @@ -2853,7 +2864,7 @@ export class ProfileModalController { return; } - if (useNip17 && !recipientRelayHints.length) { + if (this.enableNip17RelayWarning && useNip17 && !recipientRelayHints.length) { this.showStatus( "Privacy warning: this recipient has not shared NIP-17 relays, so we'll use your default relays.", { autoHideMs: 5000 }, @@ -2909,7 +2920,7 @@ export class ProfileModalController { input.value = ""; this.resetAttachmentQueue({ clearInput: true }); this.showSuccess("Message sent."); - if (result?.warning === "dm-relays-fallback") { + if (this.enableNip17RelayWarning && result?.warning === "dm-relays-fallback") { this.showStatus( "Privacy warning: this message used default relays because no NIP-17 relay list was found.", { autoHideMs: 5000 }, @@ -4509,6 +4520,10 @@ export class ProfileModalController { } handleDirectMessagesRelayWarning(detail = {}) { + if (!this.enableNip17RelayWarning) { + return; + } + if (detail?.warning !== "dm-relays-fallback") { return; } diff --git a/tests/profile-modal-controller.test.mjs b/tests/profile-modal-controller.test.mjs index 8e825092..9dec906e 100644 --- a/tests/profile-modal-controller.test.mjs +++ b/tests/profile-modal-controller.test.mjs @@ -1312,6 +1312,9 @@ test('handleDirectMessagesRelayWarning throttles status updates', async (t) => { const statusCalls = []; const controller = createController({ showStatus: (message) => statusCalls.push(message), + constants: { + ENABLE_NIP17_RELAY_WARNING: true, + }, }); await controller.load(); @@ -1330,3 +1333,19 @@ test('handleDirectMessagesRelayWarning throttles status updates', async (t) => { controller.handleDirectMessagesRelayWarning(detail); assert.equal(statusCalls.length, 2); }); + +test('handleDirectMessagesRelayWarning suppresses status updates when disabled', async (t) => { + const statusCalls = []; + const controller = createController({ + showStatus: (message) => statusCalls.push(message), + constants: { + ENABLE_NIP17_RELAY_WARNING: false, + }, + }); + await controller.load(); + + const detail = { warning: 'dm-relays-fallback' }; + + controller.handleDirectMessagesRelayWarning(detail); + assert.equal(statusCalls.length, 0); +});