aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routes/payments.js2
-rw-r--r--routes/users.js24
2 files changed, 25 insertions, 1 deletions
diff --git a/routes/payments.js b/routes/payments.js
index dc298c1a..416bc20a 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -126,7 +126,7 @@ app.get("/payments", auth, async (req, res) => {
as: "account"
},
include: {
- attrs: ["username", "profile"],
+ attributes: ["username", "profile"],
model: db.User,
as: "with"
},
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);
+ }
+});