mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Put zap splits behind a feature flag, disabled by default
This commit is contained in:
parent
3dc6963f5d
commit
1feeaf7b1e
2 changed files with 17 additions and 11 deletions
|
|
@ -262,6 +262,10 @@ class Conf {
|
||||||
static get policy(): string {
|
static get policy(): string {
|
||||||
return Deno.env.get('DITTO_POLICY') || new URL('../data/policy.ts', import.meta.url).pathname;
|
return Deno.env.get('DITTO_POLICY') || new URL('../data/policy.ts', import.meta.url).pathname;
|
||||||
}
|
}
|
||||||
|
/** Whether zap splits should be enabled. */
|
||||||
|
static get zapSplitsEnabled(): boolean {
|
||||||
|
return optionalBooleanSchema.parse(Deno.env.get('ZAP_SPLITS_ENABLED')) ?? false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const optionalBooleanSchema = z
|
const optionalBooleanSchema = z
|
||||||
|
|
|
||||||
|
|
@ -169,17 +169,19 @@ const createStatusController: AppController = async (c) => {
|
||||||
|
|
||||||
const author = await getAuthor(await c.get('signer')?.getPublicKey()!);
|
const author = await getAuthor(await c.get('signer')?.getPublicKey()!);
|
||||||
|
|
||||||
const meta = n.json().pipe(n.metadata()).catch({}).parse(author?.content);
|
if (Conf.zapSplitsEnabled) {
|
||||||
const lnurl = getLnurl(meta);
|
const meta = n.json().pipe(n.metadata()).catch({}).parse(author?.content);
|
||||||
const dittoZapSplit = await getZapSplits(store, Conf.pubkey);
|
const lnurl = getLnurl(meta);
|
||||||
if (lnurl && dittoZapSplit) {
|
const dittoZapSplit = await getZapSplits(store, Conf.pubkey);
|
||||||
let totalSplit = 0;
|
if (lnurl && dittoZapSplit) {
|
||||||
for (const pubkey in dittoZapSplit) {
|
let totalSplit = 0;
|
||||||
totalSplit += dittoZapSplit[pubkey].weight;
|
for (const pubkey in dittoZapSplit) {
|
||||||
tags.push(['zap', pubkey, Conf.relay, dittoZapSplit[pubkey].weight.toString()]);
|
totalSplit += dittoZapSplit[pubkey].weight;
|
||||||
}
|
tags.push(['zap', pubkey, Conf.relay, dittoZapSplit[pubkey].weight.toString()]);
|
||||||
if (totalSplit) {
|
}
|
||||||
tags.push(['zap', author?.pubkey as string, Conf.relay, Math.max(0, 100 - totalSplit).toString()]);
|
if (totalSplit) {
|
||||||
|
tags.push(['zap', author?.pubkey as string, Conf.relay, Math.max(0, 100 - totalSplit).toString()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue