refactor: more config options for generic config
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Kieran 2024-01-22 15:00:17 +00:00
parent 6fd02cffbb
commit 65a96eb77b
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
10 changed files with 144 additions and 55 deletions

View File

@ -17,7 +17,9 @@
"deck": true,
"zapPool": true,
"notificationGraph": true,
"communityLeaders": true
"communityLeaders": true,
"nostrAddress": true,
"pushNotifications": true
},
"signUp": {
"moderation": true,
@ -47,5 +49,9 @@
"alby": {
"clientId": "pohiJjPhQR",
"clientSecret": "GAl1YKLA3FveK1gLBYok"
}
},
"chatChannels": [
{ "type": "telegram", "value": "https://t.me/irismessenger" },
{ "type": "nip28", "value": "23286a4602ada10cc10200553bff62a110e8dc0eacddf73277395a89ddf26a09" }
]
}

View File

@ -45,5 +45,6 @@
"wss://eden.nostr.land/": { "read": true, "write": false },
"wss://relay.nostr.band/": { "read": true, "write": true },
"wss://relay.damus.io/": { "read": true, "write": true }
}
},
"chatChannels": [{ "type": "telegram", "value": "https://t.me/irismessenger" }]
}

View File

@ -16,7 +16,9 @@
"deck": false,
"zapPool": false,
"notificationGraph": true,
"communityLeaders": false
"communityLeaders": false,
"nostrAddress": false,
"pushNotifications": false
},
"signUp": {
"moderation": true,

View File

@ -1,4 +1,5 @@
/// <reference types="@webbtc/webln-types" />
/// <reference types="vite/client" />
declare module "*.jpg" {
const value: unknown;
@ -59,6 +60,8 @@ declare const CONFIG: {
zapPool: boolean;
notificationGraph: boolean;
communityLeaders: boolean;
nostrAddress: boolean;
pushNotifications: boolean;
};
defaultPreferences: {
hideMutedNotes: boolean;
@ -96,6 +99,12 @@ declare const CONFIG: {
clientId: string;
clientSecret: string;
};
// public chat channels for site
chatChannels?: Array<{
type: "nip28" | "telegram";
value: string;
}>;
};
/**

View File

@ -1,8 +1,10 @@
import { HexKey } from "@snort/system";
import { useEffect, useState, useSyncExternalStore } from "react";
import { FormattedMessage } from "react-intl";
import { Link } from "react-router-dom";
import { Link, useNavigate } from "react-router-dom";
import Telegram from "@/assets/img/telegram.svg";
import { Nip28ChatSystem } from "@/chat/nip28";
import AsyncButton from "@/Components/Button/AsyncButton";
import Copy from "@/Components/Copy/Copy";
import ZapButton from "@/Components/Event/ZapButton";
@ -64,6 +66,7 @@ const DonatePage = () => {
const [today, setSumToday] = useState<RevenueToday>();
const [onChain, setOnChain] = useState("");
const api = new SnortApi(ApiHost);
const navigate = useNavigate();
async function getOnChainAddress() {
const { address } = await api.onChainDonation();
@ -91,28 +94,24 @@ const DonatePage = () => {
return (
<div className="main-content p">
<h2>
<FormattedMessage
defaultMessage="Help fund the development of {site}"
id="yNBPJp"
values={{ site: CONFIG.appNameCapitalized }}
/>
</h2>
<p>
<FormattedMessage
defaultMessage="{site} is an open source project built by passionate people in their free time, your donations are greatly appreciated"
id="XhpBfA"
values={{ site: CONFIG.appNameCapitalized }}
defaultMessage="Snort is an open source project built by passionate people in their free time, your donations are greatly appreciated"
id="fLIvbC"
/>
</p>
<p>
<FormattedMessage
defaultMessage="Check out the code here: {link}"
id="u4bHcR"
defaultMessage="Check out the code {link}"
id="LKw/ue"
values={{
link: (
<a className="highlight" href="https://git.v0l.io/Kieran/snort" rel="noreferrer" target="_blank">
https://git.v0l.io/Kieran/snort
<a
className="highlight underline"
href="https://git.v0l.io/Kieran/snort"
rel="noreferrer"
target="_blank">
here
</a>
),
}}
@ -124,18 +123,51 @@ const DonatePage = () => {
id="VfhYxG"
values={{
here: (
<Link to="/about" className="underline">
<Link to="/about" className="highlight underline">
<FormattedMessage defaultMessage="here" id="hniz8Z" />
</Link>
),
}}
/>
</p>
<p>
<a href="https://t.me/irismessenger" target="_blank" rel="noreferrer" className="underline">
Telegram
</a>
</p>
{CONFIG.chatChannels && (
<>
<h4>
<FormattedMessage defaultMessage="Public Chat Channels" id="rn52n9" />
</h4>
<div className="flex gap-2">
{CONFIG.chatChannels.map(a => {
switch (a.type) {
case "telegram": {
return (
<AsyncButton
onClick={() => {
window.open(a.value, "_blank", "noreferrer");
}}>
<img src={Telegram} width={24} height={24} />
<FormattedMessage defaultMessage="Telegram" id="TH1fFo" />
</AsyncButton>
);
}
case "nip28": {
return (
<AsyncButton
onClick={() => {
navigate(`/messages/${Nip28ChatSystem.chatId(a.value)}`);
}}>
<img src={CONFIG.appleTouchIconUrl} width={24} height={24} className="rounded-full" />
<FormattedMessage defaultMessage="Nostr Public Chat" id="whSrs+" />
</AsyncButton>
);
}
}
})}
</div>
</>
)}
<h3>
<FormattedMessage defaultMessage="Donate" id="2IFGap" />
</h3>
<div className="flex flex-col g12">
<div className="b br p">
<div className="flex items-center justify-between">

View File

@ -45,12 +45,16 @@ const SettingsIndex = () => {
message: <FormattedMessage id="08zn6O" defaultMessage="Export Keys" />,
path: "keys",
},
{
icon: "badge",
iconBg: "bg-pink-500",
message: <FormattedMessage id="9pMqYs" defaultMessage="Nostr Address" />,
path: "handle",
},
...(CONFIG.features.nostrAddress
? [
{
icon: "badge",
iconBg: "bg-pink-500",
message: <FormattedMessage id="9pMqYs" defaultMessage="Nostr Address" />,
path: "handle",
},
]
: []),
{
icon: "gear",
iconBg: "bg-slate-500",
@ -96,18 +100,26 @@ const SettingsIndex = () => {
message: <FormattedMessage id="wofVHy" defaultMessage="Moderation" />,
path: "moderation",
},
{
icon: "bell-outline",
iconBg: "bg-red-500",
message: <FormattedMessage id="NAidKb" defaultMessage="Notifications" />,
path: "notifications",
},
{
icon: "link",
iconBg: "bg-blue-500",
message: <FormattedMessage id="hYOE+U" defaultMessage="Invite" />,
path: "invite",
},
...(CONFIG.features.pushNotifications
? [
{
icon: "bell-outline",
iconBg: "bg-red-500",
message: <FormattedMessage id="NAidKb" defaultMessage="Notifications" />,
path: "notifications",
},
]
: []),
...(CONFIG.features.communityLeaders
? [
{
icon: "link",
iconBg: "bg-blue-500",
message: <FormattedMessage id="hYOE+U" defaultMessage="Invite" />,
path: "invite",
},
]
: []),
{
icon: "hard-drive",
iconBg: "bg-cyan-500",

View File

@ -74,6 +74,9 @@ export async function sendNotification(state: LoginSession, req: NotificationReq
}
export async function subscribeToNotifications(publisher: EventPublisher) {
if (!CONFIG.features.pushNotifications) {
return;
}
// request permissions to send notifications
if ("Notification" in window) {
try {

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="1000px" height="1000px" viewBox="0 0 1000 1000" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 53.2 (72643) - https://sketchapp.com -->
<title>Artboard</title>
<desc>Created with Sketch.</desc>
<defs>
<linearGradient x1="50%" y1="0%" x2="50%" y2="99.2583404%" id="linearGradient-1">
<stop stop-color="#2AABEE" offset="0%"></stop>
<stop stop-color="#229ED9" offset="100%"></stop>
</linearGradient>
</defs>
<g id="Artboard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<circle id="Oval" fill="url(#linearGradient-1)" cx="500" cy="500" r="500"></circle>
<path d="M226.328419,494.722069 C372.088573,431.216685 469.284839,389.350049 517.917216,369.122161 C656.772535,311.36743 685.625481,301.334815 704.431427,301.003532 C708.567621,300.93067 717.815839,301.955743 723.806446,306.816707 C728.864797,310.92121 730.256552,316.46581 730.922551,320.357329 C731.588551,324.248848 732.417879,333.113828 731.758626,340.040666 C724.234007,419.102486 691.675104,610.964674 675.110982,699.515267 C668.10208,736.984342 654.301336,749.547532 640.940618,750.777006 C611.904684,753.448938 589.856115,731.588035 561.733393,713.153237 C517.726886,684.306416 492.866009,666.349181 450.150074,638.200013 C400.78442,605.66878 432.786119,587.789048 460.919462,558.568563 C468.282091,550.921423 596.21508,434.556479 598.691227,424.000355 C599.00091,422.680135 599.288312,417.758981 596.36474,415.160431 C593.441168,412.561881 589.126229,413.450484 586.012448,414.157198 C581.598758,415.158943 511.297793,461.625274 375.109553,553.556189 C355.154858,567.258623 337.080515,573.934908 320.886524,573.585046 C303.033948,573.199351 268.692754,563.490928 243.163606,555.192408 C211.851067,545.013936 186.964484,539.632504 189.131547,522.346309 C190.260287,513.342589 202.659244,504.134509 226.328419,494.722069 Z" id="Path-3" fill="#FFFFFF"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -691,6 +691,9 @@
"LF5kYT": {
"defaultMessage": "Other Connections"
},
"LKw/ue": {
"defaultMessage": "Check out the code {link}"
},
"LR1XjT": {
"defaultMessage": "Pin too short"
},
@ -902,6 +905,9 @@
"TDR5ge": {
"defaultMessage": "Media in notes will automatically be shown for selected people, otherwise only the link will show"
},
"TH1fFo": {
"defaultMessage": "Telegram"
},
"TJo5E6": {
"defaultMessage": "Preview"
},
@ -1023,9 +1029,6 @@
"XgWvGA": {
"defaultMessage": "Reactions"
},
"XhpBfA": {
"defaultMessage": "{site} is an open source project built by passionate people in their free time, your donations are greatly appreciated"
},
"Xnimz0": {
"defaultMessage": "Sending from <b>{wallet}</b>"
},
@ -1226,6 +1229,9 @@
"fBlba3": {
"defaultMessage": "Thanks for using {site}, please consider donating if you can."
},
"fLIvbC": {
"defaultMessage": "Snort is an open source project built by passionate people in their free time, your donations are greatly appreciated"
},
"fOksnD": {
"defaultMessage": "Can't vote because LNURL service does not support zaps"
},
@ -1579,6 +1585,9 @@
"rmdsT4": {
"defaultMessage": "{n} days"
},
"rn52n9": {
"defaultMessage": "Public Chat Channels"
},
"rx1i0i": {
"defaultMessage": "Short link"
},
@ -1615,9 +1624,6 @@
"u/vOPu": {
"defaultMessage": "Paid"
},
"u4bHcR": {
"defaultMessage": "Check out the code here: {link}"
},
"u9NoC1": {
"defaultMessage": "Name must be less than {limit} characters"
},
@ -1679,6 +1685,9 @@
"defaultMessage": "Anon",
"description": "Anonymous Zap"
},
"whSrs+": {
"defaultMessage": "Nostr Public Chat"
},
"wih7iJ": {
"defaultMessage": "name is blocked"
},
@ -1737,9 +1746,6 @@
"yCLnBC": {
"defaultMessage": "LNURL or Lightning Address"
},
"yNBPJp": {
"defaultMessage": "Help fund the development of {site}"
},
"zCb8fX": {
"defaultMessage": "Weight"
},

View File

@ -228,6 +228,7 @@
"KtsyO0": "Enter Pin",
"LBAnc7": "View as user?",
"LF5kYT": "Other Connections",
"LKw/ue": "Check out the code {link}",
"LR1XjT": "Pin too short",
"LXxsbk": "Anonymous",
"LgbKvU": "Comment",
@ -297,6 +298,7 @@
"Ss0sWu": "Pay Now",
"StKzTE": "The author has marked this note as a <i>sensitive topic</i>",
"TDR5ge": "Media in notes will automatically be shown for selected people, otherwise only the link will show",
"TH1fFo": "Telegram",
"TJo5E6": "Preview",
"TP/cMX": "Ended",
"TaeBqw": "Sign in with Nostr Extension",
@ -337,7 +339,6 @@
"XQiFEl": "Follows Relay Health",
"XXm7jJ": "Trending Hashtags",
"XgWvGA": "Reactions",
"XhpBfA": "{site} is an open source project built by passionate people in their free time, your donations are greatly appreciated",
"Xnimz0": "Sending from <b>{wallet}</b>",
"Xopqkl": "Your default zap amount is {number} sats, example values are calculated from this.",
"XrSk2j": "Redeem",
@ -404,6 +405,7 @@
"f2CAxA": "Dump",
"fBI91o": "Zap",
"fBlba3": "Thanks for using {site}, please consider donating if you can.",
"fLIvbC": "Snort is an open source project built by passionate people in their free time, your donations are greatly appreciated",
"fOksnD": "Can't vote because LNURL service does not support zaps",
"fQN+tq": "Show posts that have a content warning tag",
"fWZYP5": "Pinned",
@ -521,6 +523,7 @@
"rT14Ow": "Add Relays",
"rfuMjE": "(Default)",
"rmdsT4": "{n} days",
"rn52n9": "Public Chat Channels",
"rx1i0i": "Short link",
"sKDn4e": "Show Badges",
"sUNhQE": "user",
@ -533,7 +536,6 @@
"tjpYlr": "Relay Metrics",
"ttxS0b": "Supporter Badge",
"u/vOPu": "Paid",
"u4bHcR": "Check out the code here: {link}",
"u9NoC1": "Name must be less than {limit} characters",
"uCk8r+": "Already have an account?",
"uSV4Ti": "Reposts need to be manually confirmed",
@ -554,6 +556,7 @@
"wEQDC6": "Edit",
"wSZR47": "Submit",
"wWLwvh": "Anon",
"whSrs+": "Nostr Public Chat",
"wih7iJ": "name is blocked",
"wofVHy": "Moderation",
"wqyN/i": "Find out more info about {service} at {link}",
@ -573,7 +576,6 @@
"y/bmsG": "Allow",
"y1Z3or": "Language",
"yCLnBC": "LNURL or Lightning Address",
"yNBPJp": "Help fund the development of {site}",
"zCb8fX": "Weight",
"zFegDD": "Contact",
"zINlao": "Owner",