diff options
| author | Adam Soltys <[email protected]> | 2024-12-31 15:21:44 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-12-31 15:21:44 -0800 |
| commit | e2eb8a2b1a99afc8d6bc5c7a8124496ecde865c7 (patch) | |
| tree | c2739d90a714ee97f73765b8d38673b9a6ece226 /lib/utils.ts | |
| parent | ae180c75de06829075460548de026a4b0a141a7f (diff) | |
| download | coinos-server-e2eb8a2b1a99afc8d6bc5c7a8124496ecde865c7.tar.gz coinos-server-e2eb8a2b1a99afc8d6bc5c7a8124496ecde865c7.zip | |
user picture and about
Diffstat (limited to 'lib/utils.ts')
| -rw-r--r-- | lib/utils.ts | 21 |
1 files changed, 20 insertions, 1 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; }; |
