Another batch of important updates and fixes
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
const db = require('../db')
|
||||
|
||||
const Misc = {}
|
||||
|
||||
// Log a successful honeypot catch.
|
||||
Misc.logHoneypotCatch = async body => {
|
||||
await db.query('INSERT INTO honeypot_log (body_content) VALUES ($1)', [body])
|
||||
}
|
||||
|
||||
module.exports = Misc
|
||||
+11
-3
@@ -330,7 +330,15 @@ User.fetchDeserializedDataById = async userId => {
|
||||
}
|
||||
|
||||
// Fetch all registered users on the portal
|
||||
User.fetchAll = async (resultsPerPage, page) => {
|
||||
User.fetchAll = async (resultsPerPage, page, hideInactive) => {
|
||||
// hideInactive was added to hide bot spammed accounts. Using the 'inactive' status might be more appropriate as a filtering criteria in the future.
|
||||
|
||||
const whereClause = `WHERE status ${
|
||||
hideInactive
|
||||
? `= 'active' OR (status = 'registered' AND NOW() - time_registered < '${ACTIVATION_TOKEN_VALID_DAYS} days')`
|
||||
: "<> 'closed'"
|
||||
}`
|
||||
|
||||
const {
|
||||
rows: [{ result }]
|
||||
} = await db.query(
|
||||
@@ -339,7 +347,7 @@ User.fetchAll = async (resultsPerPage, page) => {
|
||||
'pages_total', (
|
||||
SELECT CEIL(COUNT(*) / $1::float)
|
||||
FROM "user"
|
||||
WHERE status <> 'closed'
|
||||
${whereClause}
|
||||
),
|
||||
'results', ARRAY(
|
||||
SELECT jsonb_build_object(
|
||||
@@ -349,7 +357,7 @@ User.fetchAll = async (resultsPerPage, page) => {
|
||||
'status', status
|
||||
)
|
||||
FROM "user"
|
||||
WHERE status <> 'closed'
|
||||
${whereClause}
|
||||
ORDER BY username
|
||||
LIMIT $1
|
||||
OFFSET $2
|
||||
|
||||
Reference in New Issue
Block a user