mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
fix: duplicate pubkey of 'self' if zap tag
This commit is contained in:
parent
92a1d88923
commit
0abd567824
1 changed files with 19 additions and 5 deletions
|
|
@ -205,12 +205,26 @@ const createStatusController: AppController = async (c) => {
|
|||
const lnurl = getLnurl(meta);
|
||||
const dittoZapSplit = await getZapSplits(store, Conf.pubkey);
|
||||
if (lnurl && dittoZapSplit) {
|
||||
let totalSplit = 0;
|
||||
for (const pubkey in dittoZapSplit) {
|
||||
totalSplit += dittoZapSplit[pubkey].weight;
|
||||
tags.push(['zap', pubkey, Conf.relay, dittoZapSplit[pubkey].weight.toString(), dittoZapSplit[pubkey].message]);
|
||||
const totalSplit = Object.values(dittoZapSplit).reduce((total, { weight }) => total + weight, 0);
|
||||
for (const zapPubkey in dittoZapSplit) {
|
||||
if (zapPubkey === pubkey) {
|
||||
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 (pubkey in dittoZapSplit === false) {
|
||||
tags.push(['zap', pubkey, Conf.relay, Math.max(0, 100 - totalSplit).toString()]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue