diff options
| author | Adam Soltys <[email protected]> | 2024-01-23 15:22:05 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-01-23 15:22:08 -0800 |
| commit | 9c7d46dbd78e4ba217adbc9d48fbd6e91f5fad99 (patch) | |
| tree | 7637d90396c0006527c44a0e69cf6f2f2a7aa0b3 /routes | |
| parent | 05967b7d4b004860113ea44cf1b01b9135437f1e (diff) | |
| download | coinos-server-9c7d46dbd78e4ba217adbc9d48fbd6e91f5fad99.tar.gz coinos-server-9c7d46dbd78e4ba217adbc9d48fbd6e91f5fad99.zip | |
format
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/nostr.js | 72 | ||||
| -rw-r--r-- | routes/users.js | 5 |
2 files changed, 41 insertions, 36 deletions
diff --git a/routes/nostr.js b/routes/nostr.js index 60b287e8..95186078 100644 --- a/routes/nostr.js +++ b/routes/nostr.js @@ -95,49 +95,51 @@ export default { async follows({ params: { pubkey }, query: { tagsonly } }, res) { try { - let sub = `${pubkey}:follows`, - params = { - limit: 1, - kinds: [3], - authors: [pubkey], - }, - opts = { timeout: 60000, eager: 60000 }; + let sub = `${pubkey}:follows`, + params = { + limit: 1, + kinds: [3], + authors: [pubkey], + }, + opts = { timeout: 60000, eager: 60000 }; - q(sub, params, opts).catch(nada); + q(sub, params, opts).catch(nada); - let tags = (await g(`${pubkey}:follows`)) || []; - if (tagsonly) return res.send(tags); + let tags = (await g(`${pubkey}:follows`)) || []; + if (tagsonly) return res.send(tags); - let follows = []; - for (let f of tags) { - let [_, pubkey] = f; + let follows = []; + for (let f of tags) { + let [_, pubkey] = f; - q(`${pubkey}:profile:f1`, { - limit: 1, - kinds: [0], - authors: [pubkey], - }).catch(nada); + q(`${pubkey}:profile:f1`, { + limit: 1, + kinds: [0], + authors: [pubkey], + }).catch(nada); - let uid = await g(`user:${pubkey}`); - let user = await g(`user:${uid}`); + let uid = await g(`user:${pubkey}`); + let user = await g(`user:${uid}`); - if (!user) - user = { - username: pubkey.substr(0, 6), - pubkey, - anon: true, - }; + if (!user) + user = { + username: pubkey.substr(0, 6), + pubkey, + anon: true, + }; - follows.push(user); - } + follows.push(user); + } - follows = uniq(follows, (e) => e.pubkey); - follows.sort((a, b) => a.username && a.username.localeCompare(b.username)); + follows = uniq(follows, (e) => e.pubkey); + follows.sort( + (a, b) => a.username && a.username.localeCompare(b.username), + ); - res.send(follows); - } catch(e) { + res.send(follows); + } catch (e) { bail(res, e.message); - } + } }, async followers({ params: { pubkey } }, res) { @@ -179,7 +181,9 @@ export default { } followers = uniq(followers, (e) => e.pubkey); - followers.sort((a, b) => a.username && a.username.localeCompare(b.username)); + followers.sort( + (a, b) => a.username && a.username.localeCompare(b.username), + ); res.send(followers); } catch (e) { diff --git a/routes/users.js b/routes/users.js index 69319ba2..230d46a1 100644 --- a/routes/users.js +++ b/routes/users.js @@ -71,8 +71,9 @@ export default { let p = await g(`payment:${pid}`); if (!p) continue; total += p.amount; - if (p.amount < 0) total -= (p.fee || 0) + (p.ourfee || 0) + (p.tip || 0); - else total += (p.tip || 0) + if (p.amount < 0) + total -= (p.fee || 0) + (p.ourfee || 0) + (p.tip || 0); + else total += p.tip || 0; } user.expected = total; |
