aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-09 12:51:00 -0700
committerAdam Soltys <[email protected]>2024-10-10 12:17:05 -0700
commitd734c424f19bbec89274d828c3a2b70dd3ef221a (patch)
tree8ec38336b345539c5ea110c2800eff79c677b19d /routes
parentc0bfa4a8a45415e16ef335219c84632f4c04f97d (diff)
downloadcoinos-server-d734c424f19bbec89274d828c3a2b70dd3ef221a.tar.gz
coinos-server-d734c424f19bbec89274d828c3a2b70dd3ef221a.zip
follows
Diffstat (limited to 'routes')
-rw-r--r--routes/nostr.ts28
-rw-r--r--routes/users.ts10
2 files changed, 15 insertions, 23 deletions
diff --git a/routes/nostr.ts b/routes/nostr.ts
index 3f801677..573424e3 100644
--- a/routes/nostr.ts
+++ b/routes/nostr.ts
@@ -1,15 +1,7 @@
import config from "$config";
import { bail, chunk, getUser, uniq } from "$lib/utils";
import { g, s, db } from "$lib/db";
-import { send, getRelays, serverPubkey, pool } from "$lib/nostr";
-
-let anon = (pubkey) => ({
- username: pubkey.substr(0, 6),
- pubkey,
- anon: true,
- follows: [],
- followers: [],
-});
+import { anon, send, getRelays, serverPubkey, pool } from "$lib/nostr";
export default {
async event(req, res) {
@@ -32,7 +24,6 @@ export default {
query: { tagsonly },
} = req;
try {
-
let filter = { kinds: [3], authors: [pubkey] };
let ev = await pool.get([config.nostr], filter);
@@ -53,19 +44,14 @@ export default {
let cache = await g(`${pubkey}:follows`);
if (cache && cache.t >= created_at) ({ follows } = cache);
else {
- let profiles = [];
let pubkeys = tags.map((t) => t[1]).filter((p) => p.length === 64);
- for (let authors of chunk(pubkeys, 100)) {
- let filter = { authors, kinds: [0] };
- profiles.push(...(await pool.querySync([config.nostr], filter)));
- }
-
let filter: any = { cache: ["user_infos", { pubkeys }] };
- let followers = JSON.parse(
- (await pool.querySync([config.cache], filter)).find(
- (e) => e.kind === 10000133,
- ).content,
- );
+ let infos = await pool.querySync([config.cache], filter);
+ let profiles = infos.filter((e) => e.kind === 0);
+
+ let f = infos.find((e) => e.kind === 10000133);
+ let followers = {};
+ if (f) followers = JSON.parse(f.content);
for (let p of profiles) {
let { content, pubkey } = p;
diff --git a/routes/users.ts b/routes/users.ts
index f907340e..e1971e78 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -87,11 +87,17 @@ export default {
if (key.length === 64) {
let nostr: any = await getProfile(key);
if (nostr) {
- nostr.username = nostr.name;
+ nostr.username = nostr.name || key.substr(0, 6);
nostr.display = nostr.display_name || nostr.displayName;
+ delete nostr.display_name;
+ delete nostr.displayName;
+ delete nostr.name;
}
- if (user) user.anon = false;
+ if (user) {
+ user.anon = false;
+ delete nostr.display;
+ }
user = {
...nostr,