mirror of
https://github.com/kind-0/nsecbunkerd.git
synced 2026-01-03 06:24:53 +00:00
setup a skeleton profile to improve UX on first load on coracle
This commit is contained in:
parent
db0c9ae3fb
commit
45e4f615a8
@ -1,4 +1,4 @@
|
||||
import { NDKPrivateKeySigner, NDKRpcRequest } from "@nostr-dev-kit/ndk";
|
||||
import NDK, { NDKEvent, NDKPrivateKeySigner, NDKRelay, NDKRpcRequest, NDKUser, NDKUserProfile, NostrEvent } from "@nostr-dev-kit/ndk";
|
||||
import AdminInterface from "../index.js";
|
||||
import { saveEncrypted } from "../../../commands/add.js";
|
||||
import { nip19 } from 'nostr-tools';
|
||||
@ -15,6 +15,10 @@ export default async function createNewKey(admin: AdminInterface, req: NDKRpcReq
|
||||
key = new NDKPrivateKeySigner(nip19.decode(_nsec).data as string);
|
||||
} else {
|
||||
key = NDKPrivateKeySigner.generate();
|
||||
|
||||
setupSkeletonProfile(key);
|
||||
|
||||
console.log(`setting up skeleton profile for ${keyName}`);
|
||||
}
|
||||
|
||||
const user = await key.user();
|
||||
@ -35,3 +39,51 @@ export default async function createNewKey(admin: AdminInterface, req: NDKRpcReq
|
||||
|
||||
return admin.rpc.sendResponse(req.id, req.pubkey, result, 24134);
|
||||
}
|
||||
|
||||
const explicitRelayUrls = [
|
||||
'wss://purplepag.es',
|
||||
'wss://relay.damus.io',
|
||||
'wss://relay.snort.social',
|
||||
'wss://relay.nostr.band',
|
||||
'wss://lbrygen.xyz',
|
||||
'wss://blastr.f7z.xyz'
|
||||
];
|
||||
|
||||
/**
|
||||
* Setup a skeleton profile for a new key since
|
||||
* the experience of a completely empty profile
|
||||
* is pretty bad when logging in with Coracle
|
||||
*/
|
||||
async function setupSkeletonProfile(key: NDKPrivateKeySigner) {
|
||||
const user = await key.user();
|
||||
const ndk = new NDK({
|
||||
explicitRelayUrls,
|
||||
signer: key
|
||||
});
|
||||
|
||||
await ndk.connect(2500);
|
||||
|
||||
user.profile = {
|
||||
name: 'New User via nsecBunker',
|
||||
bio: 'This is a skeleton profile. You should edit it.',
|
||||
website: 'https://nsecbunkerd.com',
|
||||
};
|
||||
user.ndk = ndk;
|
||||
|
||||
await user.publish();
|
||||
|
||||
const pablo = new NDKUser({npub: 'npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft'});
|
||||
await user.follow(pablo);
|
||||
|
||||
const relays = new NDKEvent(ndk, {
|
||||
kind: 10002,
|
||||
tags: [
|
||||
['r', 'wss://purplepag.es'],
|
||||
['r', 'wss://relay.f7z.io'],
|
||||
['r', 'wss://relay.snort.social'],
|
||||
['r', 'wss://relay.damus.io'],
|
||||
['r', 'wss://relay.damus.io'],
|
||||
]
|
||||
} as NostrEvent);
|
||||
await relays.publish();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user