mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Merge branch 'fix-zap-pubkey-duplication' into 'main'
fix: duplicate pubkey of 'self' if zap tag See merge request soapbox-pub/ditto!561
This commit is contained in:
commit
28b874edc9
1 changed files with 19 additions and 5 deletions
|
|
@ -205,12 +205,26 @@ const createStatusController: AppController = async (c) => {
|
||||||
const lnurl = getLnurl(meta);
|
const lnurl = getLnurl(meta);
|
||||||
const dittoZapSplit = await getZapSplits(store, Conf.pubkey);
|
const dittoZapSplit = await getZapSplits(store, Conf.pubkey);
|
||||||
if (lnurl && dittoZapSplit) {
|
if (lnurl && dittoZapSplit) {
|
||||||
let totalSplit = 0;
|
const totalSplit = Object.values(dittoZapSplit).reduce((total, { weight }) => total + weight, 0);
|
||||||
for (const pubkey in dittoZapSplit) {
|
for (const zapPubkey in dittoZapSplit) {
|
||||||
totalSplit += dittoZapSplit[pubkey].weight;
|
if (zapPubkey === pubkey) {
|
||||||
tags.push(['zap', pubkey, Conf.relay, dittoZapSplit[pubkey].weight.toString(), dittoZapSplit[pubkey].message]);
|
tags.push([
|
||||||
|
'zap',
|
||||||
|
zapPubkey,
|
||||||
|
Conf.relay,
|
||||||
|
(Math.max(0, 100 - totalSplit) + dittoZapSplit[zapPubkey].weight).toString(),
|
||||||
|
]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tags.push([
|
||||||
|
'zap',
|
||||||
|
zapPubkey,
|
||||||
|
Conf.relay,
|
||||||
|
dittoZapSplit[zapPubkey].weight.toString(),
|
||||||
|
dittoZapSplit[zapPubkey].message,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
if (totalSplit) {
|
if (totalSplit && !dittoZapSplit[pubkey]) {
|
||||||
tags.push(['zap', pubkey, Conf.relay, Math.max(0, 100 - totalSplit).toString()]);
|
tags.push(['zap', pubkey, Conf.relay, Math.max(0, 100 - totalSplit).toString()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue