aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/utils.js b/lib/utils.js
index 46267dbd..2854fefc 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -1,3 +1,4 @@
+import store from "$lib/store";
import config from "$config";
import db from "$db";
import sequelize from "@sequelize/core";
@@ -37,6 +38,26 @@ export const getUser = async (username, transaction) => {
user.haspin = !!user.pin;
+ let { pubkey } = user;
+
+ if (pubkey) {
+ store.fetching[pubkey] = true;
+ store.timeouts[pubkey] = setTimeout(
+ () => (store.fetching[pubkey] = false),
+ 500
+ );
+
+ coinos.subscribe(`${pubkey}:follows`, {
+ limit: 1,
+ kinds: [3],
+ authors: [pubkey]
+ });
+
+ await wait(() => !store.fetching[pubkey], 100, 10);
+ user.follows = JSON.parse(await redis.get(`${pubkey}:follows`));
+ user.followers = await redis.sMembers(`${pubkey}:followers`);
+ }
+
return user;
};