mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Seed zap splits when Storages.db is first accessed
This commit is contained in:
parent
31f5254fb3
commit
37f229408c
3 changed files with 9 additions and 11 deletions
|
|
@ -1,7 +1,6 @@
|
|||
// Starts up applications required to run before the HTTP server is on.
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { seedZapSplits } from '@/utils/zap-split.ts';
|
||||
import { cron } from '@/cron.ts';
|
||||
import { startFirehose } from '@/firehose.ts';
|
||||
|
||||
|
|
@ -12,5 +11,3 @@ if (Conf.firehoseEnabled) {
|
|||
if (Conf.cronEnabled) {
|
||||
cron();
|
||||
}
|
||||
|
||||
await seedZapSplits();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { SearchStore } from '@/storages/search-store.ts';
|
|||
import { InternalRelay } from '@/storages/InternalRelay.ts';
|
||||
import { NPool, NRelay1 } from '@nostrify/nostrify';
|
||||
import { getRelays } from '@/utils/outbox.ts';
|
||||
import { seedZapSplits } from '@/utils/zap-split.ts';
|
||||
|
||||
export class Storages {
|
||||
private static _db: Promise<EventsDB> | undefined;
|
||||
|
|
@ -20,7 +21,9 @@ export class Storages {
|
|||
if (!this._db) {
|
||||
this._db = (async () => {
|
||||
const kysely = await DittoDB.getInstance();
|
||||
return new EventsDB(kysely);
|
||||
const store = new EventsDB(kysely);
|
||||
await seedZapSplits(store);
|
||||
return store;
|
||||
})();
|
||||
}
|
||||
return this._db;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { handleEvent } from '@/pipeline.ts';
|
||||
import { NSchema as n, NStore } from '@nostrify/nostrify';
|
||||
import { nostrNow } from '@/utils.ts';
|
||||
import { percentageSchema } from '@/schema.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
|
||||
type Pubkey = string;
|
||||
type ExtraMessage = string;
|
||||
|
|
@ -39,11 +37,10 @@ export async function getZapSplits(store: NStore, pubkey: string): Promise<Ditto
|
|||
return zapSplits;
|
||||
}
|
||||
|
||||
export async function seedZapSplits() {
|
||||
const store = await Storages.admin();
|
||||
export async function seedZapSplits(store: NStore) {
|
||||
const zapSplit: DittoZapSplits | undefined = await getZapSplits(store, Conf.pubkey);
|
||||
|
||||
const zap_split: DittoZapSplits | undefined = await getZapSplits(store, Conf.pubkey);
|
||||
if (!zap_split) {
|
||||
if (!zapSplit) {
|
||||
const dittoPubkey = '781a1527055f74c1f70230f10384609b34548f8ab6a0a6caa74025827f9fdae5';
|
||||
const dittoMsg = 'Official Ditto Account';
|
||||
|
||||
|
|
@ -57,6 +54,7 @@ export async function seedZapSplits() {
|
|||
['p', dittoPubkey, '5', dittoMsg],
|
||||
],
|
||||
});
|
||||
await handleEvent(event, AbortSignal.timeout(5000));
|
||||
|
||||
await store.event(event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue