Merge pull request #1298 from PicPeak/fix/1296-dead-canvas-setting
fix(security): apply the Image-security defaults instead of storing them (#1296)
This commit is contained in:
@@ -229,6 +229,8 @@ async function convertToEvent(contractId, adminId) {
|
||||
|| (await resolveDefaultEventType());
|
||||
|
||||
const eventCols = await db('events').columnInfo();
|
||||
const { getImageSecurityDefaults, resolveImageSecurityColumns } = require('../../routes/adminEvents/helpers');
|
||||
const imageSecurityColumns = resolveImageSecurityColumns({}, await getImageSecurityDefaults());
|
||||
const candidate = {
|
||||
slug: `contract-${contract.contract_number.toLowerCase()}-${crypto.randomBytes(3).toString('hex')}`,
|
||||
// Prefer the contract's event_name snapshot (set on the contract
|
||||
@@ -255,6 +257,11 @@ async function convertToEvent(contractId, adminId) {
|
||||
quote_id: null,
|
||||
created_at: new Date(),
|
||||
updated_at: new Date(),
|
||||
// #1296 — a signed standalone contract converts straight to a gallery
|
||||
// here, without going through quoteService, so the global Image Security
|
||||
// defaults have to be applied on this path too. Not inside a transaction,
|
||||
// so the global db read is fine.
|
||||
...imageSecurityColumns,
|
||||
};
|
||||
const eventRow = {};
|
||||
for (const [k, v] of Object.entries(candidate)) {
|
||||
|
||||
@@ -1683,6 +1683,8 @@ async function convertToEvent(quoteId, adminId, options = {}) {
|
||||
// ask the DB which columns exist and only keep the matching pairs
|
||||
// — bullet-proof against schema drift in either direction.
|
||||
const eventCols = await trx('events').columnInfo();
|
||||
const { getImageSecurityDefaults, resolveImageSecurityColumns } = require('../routes/adminEvents/helpers');
|
||||
const imageSecurityColumns = resolveImageSecurityColumns({}, await getImageSecurityDefaults(trx));
|
||||
const candidate = {
|
||||
slug: `quote-${quote.quote_number.toLowerCase()}-${crypto.randomBytes(3).toString('hex')}`,
|
||||
event_name: quote.event_name || `Event ${quote.quote_number}`,
|
||||
@@ -1705,6 +1707,11 @@ async function convertToEvent(quoteId, adminId, options = {}) {
|
||||
quote_id: quote.id,
|
||||
created_at: new Date(),
|
||||
updated_at: new Date(),
|
||||
// #1296 — a converted quote produces a real gallery, so the global
|
||||
// Image Security defaults have to reach it too. Required lazily: this
|
||||
// is a service reaching into a route helper, and the lazy form keeps
|
||||
// the module graph acyclic the way the storage require below does.
|
||||
...imageSecurityColumns,
|
||||
};
|
||||
const eventRow = {};
|
||||
for (const [k, v] of Object.entries(candidate)) {
|
||||
|
||||
Reference in New Issue
Block a user