2024-05-14 20:55:19 +00:00
|
|
|
import { nip19 } from 'nostr-tools';
|
|
|
|
|
2024-05-24 22:40:51 +00:00
|
|
|
import { DittoDB } from '@/db/DittoDB.ts';
|
|
|
|
import { Storages } from '@/storages.ts';
|
|
|
|
import { refreshAuthorStats } from '@/utils/stats.ts';
|
2024-05-14 20:55:19 +00:00
|
|
|
|
|
|
|
let pubkey: string;
|
|
|
|
try {
|
|
|
|
const result = nip19.decode(Deno.args[0]);
|
|
|
|
if (result.type === 'npub') {
|
|
|
|
pubkey = result.data;
|
|
|
|
} else {
|
|
|
|
throw new Error('Invalid npub');
|
|
|
|
}
|
|
|
|
} catch {
|
|
|
|
console.error('Invalid npub');
|
|
|
|
Deno.exit(1);
|
|
|
|
}
|
|
|
|
|
2024-05-24 22:40:51 +00:00
|
|
|
const store = await Storages.db();
|
|
|
|
const kysely = await DittoDB.getInstance();
|
|
|
|
|
|
|
|
await refreshAuthorStats({ pubkey, kysely, store });
|