TODO: Fix timestamps sent by API. Possibly move conversion to roblox server-side
This commit is contained in:
parent
a7f79e906e
commit
6ec616515b
2
index.js
2
index.js
|
@ -154,7 +154,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (discordId) {
|
if (discordId) {
|
||||||
discordUsername = (await client.users.fetch(discordId)).username || "Unknown"
|
discordUsername = (await client.users.fetch(discordId))?.username || "Unknown"
|
||||||
} else {
|
} else {
|
||||||
discordUsername = null
|
discordUsername = null
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@ router.get('/v1/bans', async (req, res) => {
|
||||||
const rows = await connection.query('SELECT * FROM bans');
|
const rows = await connection.query('SELECT * FROM bans');
|
||||||
// Convert all timestamps into epoch
|
// Convert all timestamps into epoch
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
row.expiresTimestamp = row.expiresTimestamp ? row.expiresTimestamp.getTime() : null
|
row.expiresTimestamp = row.expiresTimestamp ? new Date(row.expiresTimestamp).getTime() : null
|
||||||
row.banTimestamp = row.banTimestamp ? row.banTimestamp.getTime() : null
|
row.banTimestamp = row.banTimestamp ? new Date(row.banTimestamp).getTime() : null
|
||||||
|
row.currentServerTime = new Date().getTime();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send the results as a JSON response
|
// Send the results as a JSON response
|
||||||
res.json(rows);
|
res.json(rows);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -56,8 +56,9 @@ router.get("/v1/ban/roblox/:uid", async (req, res) => {
|
||||||
const rows = await connection.query('SELECT * FROM bans WHERE robloxId = ?', [req.params.uid]);
|
const rows = await connection.query('SELECT * FROM bans WHERE robloxId = ?', [req.params.uid]);
|
||||||
// Convert all timestamps into epoch
|
// Convert all timestamps into epoch
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
row.expiresTimestamp = row.expiresTimestamp ? row.expiresTimestamp.getTime() : null
|
row.expiresTimestamp = row.expiresTimestamp ? new Date(row.expiresTimestamp).getTime() : null
|
||||||
row.banTimestamp = row.banTimestamp ? row.banTimestamp.getTime() : null
|
row.banTimestamp = row.banTimestamp ? new Date(row.banTimestamp).getTime() : null
|
||||||
|
row.currentServerTime = new Date().getTime();
|
||||||
});
|
});
|
||||||
// Send the results as a JSON response
|
// Send the results as a JSON response
|
||||||
res.json(rows);
|
res.json(rows);
|
||||||
|
@ -84,9 +85,11 @@ router.get("/v1/ban/discord/:uid", async (req, res) => {
|
||||||
const rows = await connection.query('SELECT * FROM bans WHERE discordId = ?', [req.params.uid]);
|
const rows = await connection.query('SELECT * FROM bans WHERE discordId = ?', [req.params.uid]);
|
||||||
// Convert all timestamps into epoch
|
// Convert all timestamps into epoch
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
row.expiresTimestamp = row.expiresTimestamp ? row.expiresTimestamp.getTime() : null
|
row.expiresTimestamp = row.expiresTimestamp ? new Date(row.expiresTimestamp).getTime() : null
|
||||||
row.banTimestamp = row.banTimestamp ? row.banTimestamp.getTime() : null
|
row.banTimestamp = row.banTimestamp ? new Date(row.banTimestamp).getTime() : null
|
||||||
|
row.currentServerTime = new Date().getTime();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send the results as a JSON response
|
// Send the results as a JSON response
|
||||||
res.json(rows);
|
res.json(rows);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -104,7 +107,8 @@ router.get("/v1/ban/discord/:uid", async (req, res) => {
|
||||||
router.get("/v1/info", (req,res) => {
|
router.get("/v1/info", (req,res) => {
|
||||||
res.json({
|
res.json({
|
||||||
commit_hash: execSync('git rev-parse HEAD').toString().trim(),
|
commit_hash: execSync('git rev-parse HEAD').toString().trim(),
|
||||||
reasonFlags
|
reasonFlags,
|
||||||
|
currentServerTime: new Date().getTime()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue