From bce404728b42c9cb5f3236e77d550062994b6040 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Mon, 5 Aug 2024 16:20:38 -0300 Subject: [PATCH] refactor: rename zap_split to dittoZapSplit --- src/controllers/api/ditto.ts | 22 +++++++++++----------- src/controllers/api/statuses.ts | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/controllers/api/ditto.ts b/src/controllers/api/ditto.ts index e181f11e..ed1f500d 100644 --- a/src/controllers/api/ditto.ts +++ b/src/controllers/api/ditto.ts @@ -173,8 +173,8 @@ export const updateZapSplitsController: AppController = async (c) => { return c.json({ error: result.error }, 400); } - const zap_split = await getZapSplits(store, Conf.pubkey); - if (!zap_split) { + const dittoZapSplit = await getZapSplits(store, Conf.pubkey); + if (!dittoZapSplit) { return c.json({ error: 'Zap split not activated, restart the server.' }, 404); } @@ -208,8 +208,8 @@ export const deleteZapSplitsController: AppController = async (c) => { return c.json({ error: result.error }, 400); } - const zap_split = await getZapSplits(store, Conf.pubkey); - if (!zap_split) { + const dittoZapSplit = await getZapSplits(store, Conf.pubkey); + if (!dittoZapSplit) { return c.json({ error: 'Zap split not activated, restart the server.' }, 404); } @@ -230,24 +230,24 @@ export const deleteZapSplitsController: AppController = async (c) => { export const getZapSplitsController: AppController = async (c) => { const store = c.get('store'); - const zap_split: DittoZapSplits | undefined = await getZapSplits(store, Conf.pubkey) ?? {}; - if (!zap_split) { + const dittoZapSplit: DittoZapSplits | undefined = await getZapSplits(store, Conf.pubkey) ?? {}; + if (!dittoZapSplit) { return c.json({ error: 'Zap split not activated, restart the server.' }, 404); } - const pubkeys = Object.keys(zap_split); + const pubkeys = Object.keys(dittoZapSplit); - const zapSplitEntity = await Promise.all(pubkeys.map(async (pubkey) => { + const zapSplits = await Promise.all(pubkeys.map(async (pubkey) => { const author = await getAuthor(pubkey); const account = author ? await renderAccount(author) : await accountFromPubkey(pubkey); return { account, - weight: zap_split[pubkey].weight, - message: zap_split[pubkey].message, + weight: dittoZapSplit[pubkey].weight, + message: dittoZapSplit[pubkey].message, }; })); - return c.json(zapSplitEntity, 200); + return c.json(zapSplits, 200); }; diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index f875b785..16c4c8bf 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -179,12 +179,12 @@ const createStatusController: AppController = async (c) => { const meta = n.json().pipe(n.metadata()).catch({}).parse(author?.content); const lnurl = getLnurl(meta); - const zap_split = await getZapSplits(store, Conf.pubkey); - if (lnurl && zap_split) { + const dittoZapSplit = await getZapSplits(store, Conf.pubkey); + if (lnurl && dittoZapSplit) { let totalSplit = 0; - for (const pubkey in zap_split) { - totalSplit += zap_split[pubkey].weight; - tags.push(['zap', pubkey, Conf.relay, zap_split[pubkey].weight.toString()]); + for (const pubkey in dittoZapSplit) { + 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()]);