aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/nostr.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/nostr.js b/lib/nostr.js
index 53c8d7d1..477d2b12 100644
--- a/lib/nostr.js
+++ b/lib/nostr.js
@@ -18,6 +18,8 @@ let timeout;
pool.on("event", async (relay, sub, ev) => {
try {
if (sub === "live") {
+ let { pubkey } = ev;
+
if (Math.abs(Math.floor(Date.now() / 1000) - ev.created_at) > 7200)
return;
@@ -34,16 +36,31 @@ pool.on("event", async (relay, sub, ev) => {
}
coinos.send(["EVENT", ev]);
- if (ev.kind === 1) broadcast("event", ev);
+
+ ev.user = JSON.parse(await redis.get(`user:${pubkey}`)) || {
+ username: pubkey.substr(0, 6),
+ pubkey,
+ anon: true
+ };
+
+ if (ev.kind === 1) {
+ broadcast("event", ev);
+ }
}
} else {
let pubkey = sub;
clearTimeout(store.timeouts[pubkey]);
- store.fetching[pubkey] = true;
+ ev.user = JSON.parse(await redis.get(`user:${pubkey}`)) || {
+ username: pubkey.substr(0, 6),
+ pubkey,
+ anon: true
+ };
+
await redis.sAdd(pubkey, ev.id);
await redis.set(`ev:${ev.id}`, JSON.stringify(ev));
+ store.fetching[pubkey] = true;
store.timeouts[pubkey] = setTimeout(
() => (store.fetching[pubkey] = false),
100