aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-12-31 15:21:44 -0800
committerAdam Soltys <[email protected]>2024-12-31 15:21:44 -0800
commite2eb8a2b1a99afc8d6bc5c7a8124496ecde865c7 (patch)
treec2739d90a714ee97f73765b8d38673b9a6ece226
parentae180c75de06829075460548de026a4b0a141a7f (diff)
downloadcoinos-server-e2eb8a2b1a99afc8d6bc5c7a8124496ecde865c7.tar.gz
coinos-server-e2eb8a2b1a99afc8d6bc5c7a8124496ecde865c7.zip
user picture and about
-rw-r--r--lib/utils.ts21
-rw-r--r--lib/whitelist.ts1
-rw-r--r--routes/users.ts16
3 files changed, 30 insertions, 8 deletions
diff --git a/lib/utils.ts b/lib/utils.ts
index 7fc1f4e7..278a2c82 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -71,14 +71,33 @@ export const fields = [
];
export const getUser = async (username) => {
+ let update;
if (username === "undefined") fail("invalid user");
const user = await migrate(username);
if (user && !user.anon && !user.nwc) {
user.nwc = bytesToHex(randomBytes(32));
await s(getPublicKey(user.nwc), user.id);
- await s(`user:${user.id}`, user);
+ update = true;
}
+ if (user.profile) {
+ user.picture = `https://coinos.io/api/public/${user.profile}.webp`;
+ delete user.profile;
+
+ if (user.banner) {
+ user.banner = `https://coinos.io/api/public/${user.banner}.webp`;
+ }
+ update = true;
+ }
+
+ if (user.address) {
+ user.about = user.address;
+ delete user.address;
+ update = true;
+ }
+
+ if (update) s(`user:${user.id}`, user);
+
return user;
};
diff --git a/lib/whitelist.ts b/lib/whitelist.ts
index 285afe8a..16594a4b 100644
--- a/lib/whitelist.ts
+++ b/lib/whitelist.ts
@@ -1,5 +1,4 @@
export default [
- "address",
"admin",
"anon",
"autowithdraw",
diff --git a/routes/users.ts b/routes/users.ts
index 3b35a35c..d2992d1b 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -116,7 +116,6 @@ export default {
const whitelist = [
"about",
- "address",
"anon",
"banner",
"banner",
@@ -254,7 +253,7 @@ export default {
}
const attributes = [
- "address",
+ "about",
"autowithdraw",
"banner",
"cipher",
@@ -263,25 +262,25 @@ export default {
"destination",
"display",
"email",
- "language",
"fiat",
+ "language",
"locktime",
"memoPrompt",
"nip5",
"notify",
"nsec",
- "prompt",
"profile",
+ "prompt",
"pubkey",
"push",
"reserve",
"salt",
"seed",
+ "shopifyStore",
+ "shopifyToken",
"threshold",
"tokens",
"twofa",
- "shopifyToken",
- "shopifyStore",
];
for (const a of attributes) {
@@ -389,6 +388,11 @@ export default {
};
user = await register(user, ip);
+ user.display = k0.display_name || k0.displayName;
+ user.picture = k0.picture;
+ user.banner = k0.banner;
+ user.about = k0.about;
+ await s(`user:${user.id}`, user);
}
const { username } = user;