aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-13 13:03:36 -0800
committerAdam Soltys <[email protected]>2023-02-13 13:03:36 -0800
commitf7307a8e2d627006dd6e72fe9c1e2e4d5c6e312a (patch)
tree9f96770618e2d4bb728001297b4d7f188be25619 /lib
parent270b781306358f791caeab993aaa0f2c565eaf0a (diff)
downloadcoinos-server-f7307a8e2d627006dd6e72fe9c1e2e4d5c6e312a.tar.gz
coinos-server-f7307a8e2d627006dd6e72fe9c1e2e4d5c6e312a.zip
nostr fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/nostr.js23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/nostr.js b/lib/nostr.js
index 065fafb0..b6f5f50d 100644
--- a/lib/nostr.js
+++ b/lib/nostr.js
@@ -5,12 +5,13 @@ import store from "$lib/store";
import { g, s, db } from "$lib/db";
import { nada, wait } from "$lib/utils";
+export let coinos;
export let pool;
export let fillPool = () => {
pool = RelayPool(config.relays);
pool.on("open", relay => {
- if (relay.url.includes(config.relay)) coinos = relay;
+ if (relay.url.includes(config.nostr)) coinos = relay;
relay.subscribe("live", { limit: 1 });
});
@@ -61,7 +62,7 @@ export let fillPool = () => {
coinos.send(ev);
} else if (sub.includes("follows")) {
let pubkey = sub.split(":")[0];
- await s(`${pubkey}:follows`, JSON.stringify(ev.tags));
+ await s(`${pubkey}:follows`, ev.tags);
for (let f of ev.tags) {
let [_, followPubkey] = f;
await db.sAdd(`${followPubkey}:followers`, pubkey);
@@ -83,7 +84,6 @@ export let fillPool = () => {
});
};
-export let coinos;
let now = () => Math.round(Date.now() / 1000);
let timeouts = {};
@@ -156,9 +156,14 @@ export let q = async (
let seen = [];
-let getUser = async pubkey =>
- JSON.parse(await g(`user:${pubkey}`)) || {
- username: pubkey.substr(0, 6),
- pubkey,
- anon: true
- };
+let getUser = async pubkey => {
+ let id = await g(`user:${pubkey}`);
+ let user = await g(`user:${id}`);
+ return (
+ user || {
+ username: pubkey.substr(0, 6),
+ pubkey,
+ anon: true
+ }
+ );
+};