aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-12-22 13:42:00 -0800
committerAdam Soltys <[email protected]>2022-12-22 13:42:00 -0800
commita487b5a2b80d270771f9932c17d2b6babf0fd49a (patch)
tree86d2b894f33d383012752e0a1bd01744f2548fb3 /routes
parent728ac80f9cc8a3268bdced6339f58936bd69648b (diff)
downloadcoinos-server-a487b5a2b80d270771f9932c17d2b6babf0fd49a.tar.gz
coinos-server-a487b5a2b80d270771f9932c17d2b6babf0fd49a.zip
return mock user objects for anon pubkeys
Diffstat (limited to 'routes')
-rw-r--r--routes/events.js8
-rw-r--r--routes/users.js9
2 files changed, 16 insertions, 1 deletions
diff --git a/routes/events.js b/routes/events.js
index 18abf1d7..07062140 100644
--- a/routes/events.js
+++ b/routes/events.js
@@ -1,4 +1,5 @@
import app from "$app";
+import db from "$db";
import redis from "$lib/redis";
import { pool } from "$lib/nostr";
import store from "$lib/store";
@@ -13,6 +14,13 @@ app.get("/:pubkey/events", async (req, res) => {
500
);
+ let user = await db.User.findOne({
+ where: { pubkey }
+ });
+
+ if (!user) user = { username: pubkey.substr(0,6), pubkey, anon: true }
+ await redis.set(`user:${pubkey}`, JSON.stringify(user));
+
pool.subscribe(pubkey, {
limit: 500,
kinds: [1],
diff --git a/routes/users.js b/routes/users.js
index 82a71549..70186145 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -57,7 +57,14 @@ app.get("/users/:username", async (req, res) => {
const { username } = req.params;
let user = await db.User.findOne({
- attributes: ["username", "banner", "profile", "address", "currency"],
+ attributes: [
+ "username",
+ "banner",
+ "profile",
+ "address",
+ "currency",
+ "pubkey"
+ ],
where: Sequelize.where(
Sequelize.fn("lower", Sequelize.col("username")),
username.toLowerCase()