diff options
| author | Adam Soltys <[email protected]> | 2022-11-11 11:56:14 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-11-11 11:56:14 -0800 |
| commit | 9b4e84941531ba97c3dc836524d1b84ee75ffcaa (patch) | |
| tree | d658228ec88214b46b7ce3999ec4f9b88a427230 /routes/users.js | |
| parent | 34cecd097f152a4816042e790253cc9db62a6ba0 (diff) | |
| download | coinos-server-9b4e84941531ba97c3dc836524d1b84ee75ffcaa.tar.gz coinos-server-9b4e84941531ba97c3dc836524d1b84ee75ffcaa.zip | |
contacts endpoint
Diffstat (limited to 'routes/users.js')
| -rw-r--r-- | routes/users.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/routes/users.js b/routes/users.js index 6181a957..c3ceb35e 100644 --- a/routes/users.js +++ b/routes/users.js @@ -660,3 +660,27 @@ app.post("/otpsecret", auth, async function(req, res) { res.code(500).send(e.message); } }); + +app.get("/contacts", auth, async function(req, res) { + try { + let contacts = await db.Payment.findAll({ + where: { + user_id: req.user.id, + with_id: { [Sequelize.Op.ne]: null } + }, + include: { + attributes: ["username", "profile"], + model: db.User, + as: "with" + }, + attributes: ["id"], + group: ["with_id"], + order: [[{ model: db.User, as: "with" }, "username", "ASC"]] + }); + + res.send(contacts.map(c => c.with)); + } catch (e) { + console.log(e); + res.code(500).send(e.message); + } +}); |
