mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor: rename zap_split to dittoZapSplit
This commit is contained in:
parent
0a3ed4e160
commit
bce404728b
2 changed files with 16 additions and 16 deletions
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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()]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue