mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-05 20:32:27 +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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user