aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db/index.js5
-rw-r--r--db/models/payments.js9
-rw-r--r--lib/sendInternal.js5
-rw-r--r--lib/sockets.js2
-rw-r--r--routes/payments.js5
-rw-r--r--routes/users.js2
6 files changed, 24 insertions, 4 deletions
diff --git a/db/index.js b/db/index.js
index 8c94a4d3..81c0fe46 100644
--- a/db/index.js
+++ b/db/index.js
@@ -124,6 +124,11 @@ Payment.belongsTo(Payment, {
foreignKey: "fee_payment_id"
});
+Payment.belongsTo(User, {
+ as: "with",
+ foreignKey: "with_id"
+});
+
db.Order = Order;
export default db;
diff --git a/db/models/payments.js b/db/models/payments.js
index b3ac0b74..fac8ff56 100644
--- a/db/models/payments.js
+++ b/db/models/payments.js
@@ -11,6 +11,15 @@ const attributes = {
comment: null,
field: "id"
},
+ with_id: {
+ type: DataTypes.INTEGER(11),
+ allowNull: true,
+ defaultValue: null,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "with_id"
+ },
account_id: {
type: DataTypes.INTEGER(11),
allowNull: true,
diff --git a/lib/sendInternal.js b/lib/sendInternal.js
index 3090e94a..640587b5 100644
--- a/lib/sendInternal.js
+++ b/lib/sendInternal.js
@@ -139,7 +139,8 @@ export default async (
hash: `#${v4().substr(0, 6)} Payment from ${user.username}`,
memo,
network: "COINOS",
- received: true
+ received: true,
+ with_id: user.id
};
if (invoice) {
@@ -194,7 +195,7 @@ export default async (
hash: `#${v4().substr(0, 6)} ${
username ? `Payment to ${username}` : "Internal Transfer"
}`,
- network: "COINOS"
+ network: "COINOS",
};
if (!username) {
diff --git a/lib/sockets.js b/lib/sockets.js
index 87cf7116..fb007a17 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -85,7 +85,7 @@ app.register(async function(app) {
switch (type) {
case "heartbeat":
ws.beats = 0;
- if (ws.user) emit(ws.user.username, "id", ws.id);
+ ws.send(JSON.stringify({ type: "id", data: ws.id }));
break;
case "login":
diff --git a/routes/payments.js b/routes/payments.js
index d60d4e2e..dc298c1a 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -125,6 +125,11 @@ app.get("/payments", auth, async (req, res) => {
model: db.Account,
as: "account"
},
+ include: {
+ attrs: ["username", "profile"],
+ model: db.User,
+ as: "with"
+ },
limit,
offset
});
diff --git a/routes/users.js b/routes/users.js
index da8dfca0..b142eb3a 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -57,7 +57,7 @@ app.get("/users/:username", async (req, res) => {
const { username } = req.params;
const user = await db.User.findOne({
- attributes: ["username", "banner", "profile", "address"],
+ attributes: ["username", "banner", "profile", "address", "currency"],
where: Sequelize.where(
Sequelize.fn("lower", Sequelize.col("username")),
username.toLowerCase()