aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nostr.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-16 22:43:43 -0800
committerAdam Soltys <[email protected]>2023-02-16 22:43:43 -0800
commitd01995b438fc2bde316f9cc7020c01d71cd9d288 (patch)
treea6d5cf9cec203b6c77cdf5f2b4baef2202baca60 /lib/nostr.js
parent8b9497ec3349a584c90d2ac782c634f7f328c19f (diff)
downloadcoinos-server-d01995b438fc2bde316f9cc7020c01d71cd9d288.tar.gz
coinos-server-d01995b438fc2bde316f9cc7020c01d71cd9d288.zip
emit messages
Diffstat (limited to 'lib/nostr.js')
-rw-r--r--lib/nostr.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/nostr.js b/lib/nostr.js
index fdea9d62..2eb59ae7 100644
--- a/lib/nostr.js
+++ b/lib/nostr.js
@@ -1,6 +1,6 @@
import config from "$config";
import { Relay, RelayPool } from "nostr";
-import { broadcast } from "$lib/sockets";
+import { broadcast, emit } from "$lib/sockets";
import store from "$lib/store";
import { g, s, db } from "$lib/db";
import { nada, wait } from "$lib/utils";
@@ -40,6 +40,13 @@ export let fillPool = () => {
// coinos.send(["EVENT", ev]);
ev.user = await getUser(pubkey);
// broadcast("event", ev);
+
+ if (ev.kind === 4) {
+ let uid = await g(`user:${ev.tags[0][1]}`);
+ if (uid) ev.recipient = await g(`user:${uid}`);
+ ev.author = ev.user;
+ emit(uid, "event", ev);
+ }
}
} else if (sub.includes("profile")) {
let { pubkey } = ev;