Put zap splits behind a feature flag, disabled by default

This commit is contained in:
Alex Gleason 2024-08-14 22:05:17 -05:00
parent 3dc6963f5d
commit 1feeaf7b1e
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 17 additions and 11 deletions

View file

@ -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

View file

@ -169,6 +169,7 @@ const createStatusController: AppController = async (c) => {
const author = await getAuthor(await c.get('signer')?.getPublicKey()!); const author = await getAuthor(await c.get('signer')?.getPublicKey()!);
if (Conf.zapSplitsEnabled) {
const meta = n.json().pipe(n.metadata()).catch({}).parse(author?.content); const meta = n.json().pipe(n.metadata()).catch({}).parse(author?.content);
const lnurl = getLnurl(meta); const lnurl = getLnurl(meta);
const dittoZapSplit = await getZapSplits(store, Conf.pubkey); const dittoZapSplit = await getZapSplits(store, Conf.pubkey);
@ -182,6 +183,7 @@ const createStatusController: AppController = async (c) => {
tags.push(['zap', author?.pubkey as string, Conf.relay, Math.max(0, 100 - totalSplit).toString()]); tags.push(['zap', author?.pubkey as string, Conf.relay, Math.max(0, 100 - totalSplit).toString()]);
} }
} }
}
const event = await createEvent({ const event = await createEvent({
kind: 1, kind: 1,