CJVT updates August and September 2026

This commit is contained in:
Luka Romih
2026-10-01 00:49:26 +02:00
parent fd02e25719
commit 83f73aeb58
135 changed files with 6146 additions and 1970 deletions
+48 -1
View File
@@ -1,6 +1,6 @@
/* global __ */
const { getInstanceSetting } = require('../../models/helpers')
const { getInstanceSetting, intoDbArray } = require('../../models/helpers')
const Dictionary = require('../../models/dictionary')
const cache = require('../../models/cache')
const { promisify } = require('util')
@@ -194,6 +194,53 @@ exports.statusChangeCheckAndAct = {
}
}
// Whitelist of admin dictionary-list sortable columns, keeping req.query
// values from ever reaching raw SQL - see models/dictionary.js
// fetchAllAdminDictionaries.
const DICTIONARY_LIST_SORT_COLUMNS = [
'id',
'name',
'status',
'timeCreated',
'timeModified'
]
// Resolves the admin dictionary-list sort params from a request query,
// defaulting to id/desc when absent or invalid.
exports.resolveDictionarySort = (querySort, queryDir) => ({
sortBy: DICTIONARY_LIST_SORT_COLUMNS.includes(querySort) ? querySort : 'id',
sortDir: queryDir === 'asc' ? 'asc' : 'desc'
})
const DICTIONARY_STATUSES = ['closed', 'reviewed', 'published']
exports.DICTIONARY_STATUSES = DICTIONARY_STATUSES
// Keeps only numeric-looking id strings, matching the option values the
// admin filter selects render (real DB smallint ids) - drops anything else
// rather than letting it reach a ::smallint[] cast in SQL.
const toNumericIdArray = ids => {
if (!ids) return null
const numericIds = ids.filter(id => /^\d+$/.test(id))
return numericIds.length > 0 ? numericIds : null
}
// Parses/whitelists the admin dictionary-list search+filter params from a
// request query. A filter category left unselected resolves to null ("no
// filter"), never an empty array (which would match zero rows in SQL).
exports.parseDictionaryListFilters = query => {
const rawStatuses = intoDbArray(query.status)
const statuses = rawStatuses
? rawStatuses.filter(value => DICTIONARY_STATUSES.includes(value))
: null
return {
nameQuery: typeof query.q === 'string' ? query.q.trim() : '',
primaryDomainIds: toNumericIdArray(intoDbArray(query.pd)),
secondaryDomainIds: toNumericIdArray(intoDbArray(query.sd)),
languageIds: toNumericIdArray(intoDbArray(query.lang)),
statuses: statuses && statuses.length > 0 ? statuses : null
}
}
// Helper function used by statusChangeCheckAndAct methods.
async function renderAndSendStatusChangeEmails(
appRef,