mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
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 <[email protected]>
This commit is contained in:
1 parent
83d8023767
commit
5ca378bb96
5 files changed
+53
-4
No files matched your search
@@ -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;
|
||||
@@ -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.",
|
||||
);
|
||||
|
||||
@@ -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 };
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user