mirror of
https://github.com/aljazceru/hypergolic.git
synced 2026-02-01 03:34:22 +01:00
problem: we are querying zap providers too often
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e.pubkey && $currentUser && e.pubkey == $currentUser.pubkey) {
|
||||
if (e && e.pubkey && $currentUser && e.pubkey == $currentUser.pubkey) {
|
||||
alert(
|
||||
'Nostrocket could not validate that the zap receipts published on your behalf are legitimate, this usually means we could not query your lightning service provider API. Consider switching to a lightning service provider that is known to work (e.g. getAlby).'
|
||||
);
|
||||
|
||||
@@ -6,6 +6,8 @@ import { sha256 } from 'js-sha256';
|
||||
import { MapOfVotes, MeritRequest, Votes } from './merits';
|
||||
import * as immutable from 'immutable';
|
||||
import { BloomFilter } from 'bloomfilter';
|
||||
import { zappers } from '@/stores/zappers';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export class Rocket {
|
||||
Event: NDKEvent;
|
||||
@@ -739,20 +741,24 @@ export function RocketATagFilter(rocket: NDKEvent): string {
|
||||
|
||||
export async function ValidateZapPublisher(rocket: NDKEvent, zap: NDKEvent): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
getAuthorizedZapper(rocket)
|
||||
.then((pubkey) => {
|
||||
if (pubkey == zap.pubkey) {
|
||||
resolve(true);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
})
|
||||
.catch((e) => reject(e));
|
||||
// let z = new NDKZap({ ndk: rocket.ndk!, zappedEvent: rocket, zappedUser: rocket.author });
|
||||
// z.getZapEndpoint().then(x=>{
|
||||
// console.log(x)
|
||||
// resolve(true)
|
||||
// }).catch(()=>{reject(false)})
|
||||
let zapper = get(zappers).get(rocket.pubkey);
|
||||
if (zapper && zapper == zap.pubkey) {
|
||||
resolve(true);
|
||||
} else {
|
||||
getAuthorizedZapper(rocket)
|
||||
.then((pubkey) => {
|
||||
if (pubkey == zap.pubkey) {
|
||||
zappers.update((existing) => {
|
||||
existing.set(rocket.pubkey, pubkey);
|
||||
return existing;
|
||||
});
|
||||
resolve(true);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
})
|
||||
.catch((e) => reject(e));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,6 @@ export async function getAuthorizedZapper(rocket: NDKEvent): Promise<string> {
|
||||
z.getZapEndpoint()
|
||||
.then((url) => {
|
||||
if (url) {
|
||||
console.log(url);
|
||||
url = url.trim().replace('/callback', '');
|
||||
fetch(url).then((result) => {
|
||||
result
|
||||
|
||||
3
src/lib/stores/zappers.ts
Normal file
3
src/lib/stores/zappers.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export let zappers = writable(new Map<string, string>());
|
||||
Reference in New Issue
Block a user