Fixes of bugs caused by the public endpoint.
This commit is contained in:
parent
efbfa2b366
commit
213039c141
10 changed files with 79 additions and 52 deletions
|
|
@ -14,6 +14,8 @@ const { formatDate, formatBirthday, parseDate, parseBirthday } = require('../sha
|
|||
const { getFieldColumn } = require('../shared/lists');
|
||||
const { cleanupFromPost } = require('../lib/helpers');
|
||||
const Handlebars = require('handlebars');
|
||||
const { getTrustedUrl, getSandboxUrl, getPublicUrl } = require('../lib/urls');
|
||||
const { getMergeTagsForBases } = require('../shared/templates');
|
||||
|
||||
|
||||
const allowedKeysCreate = new Set(['name', 'key', 'default_value', 'type', 'group', 'settings']);
|
||||
|
|
@ -228,7 +230,7 @@ fieldTypes['date'] = {
|
|||
getHbsType: field => 'typeDate' + field.settings.dateFormat.charAt(0).toUpperCase() + field.settings.dateFormat.slice(1),
|
||||
forHbs: (field, value) => formatDate(field.settings.dateFormat, value),
|
||||
parsePostValue: (field, value) => parseDate(field.settings.dateFormat, value),
|
||||
render: (field, value) => value !== null && value.trim() !== '' ? formatDate(field.settings.dateFormat, value) : ''
|
||||
render: (field, value) => value !== null ? formatDate(field.settings.dateFormat, value) : ''
|
||||
};
|
||||
|
||||
fieldTypes['birthday'] = {
|
||||
|
|
@ -243,7 +245,7 @@ fieldTypes['birthday'] = {
|
|||
getHbsType: field => 'typeBirthday' + field.settings.dateFormat.charAt(0).toUpperCase() + field.settings.dateFormat.slice(1),
|
||||
forHbs: (field, value) => formatBirthday(field.settings.dateFormat, value),
|
||||
parsePostValue: (field, value) => parseBirthday(field.settings.dateFormat, value),
|
||||
render: (field, value) => value !== null && value.trim() !== '' ? formatBirthday(field.settings.dateFormat, value) : ''
|
||||
render: (field, value) => value !== null ? formatBirthday(field.settings.dateFormat, value) : ''
|
||||
};
|
||||
|
||||
const groupedTypes = Object.keys(fieldTypes).filter(key => fieldTypes[key].grouped);
|
||||
|
|
@ -694,7 +696,8 @@ async function forHbs(context, listId, subscription) { // assumes grouped subscr
|
|||
|
||||
function getMergeTags(fieldsGrouped, subscription) { // assumes grouped subscription
|
||||
const mergeTags = {
|
||||
'EMAIL': subscription.email
|
||||
'EMAIL': subscription.email,
|
||||
...getMergeTagsForBases(getTrustedUrl(), getSandboxUrl(), getPublicUrl())
|
||||
};
|
||||
|
||||
for (const fld of fieldsGrouped) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const fs = require('fs-extra-promise');
|
|||
const path = require('path');
|
||||
const interoperableErrors = require('../shared/interoperable-errors');
|
||||
const entitySettings = require('../lib/entity-settings');
|
||||
const {getTrustedUrl} = require('../lib/urls');
|
||||
const {getPublicUrl} = require('../lib/urls');
|
||||
|
||||
const crypto = require('crypto');
|
||||
const bluebird = require('bluebird');
|
||||
|
|
@ -29,7 +29,7 @@ function getFilePath(type, subType, entityId, filename) {
|
|||
}
|
||||
|
||||
function getFileUrl(context, type, subType, entityId, filename) {
|
||||
return getTrustedUrl(`files/${type}/${subType}/${entityId}/${filename}`, context)
|
||||
return getPublicUrl(`files/${type}/${subType}/${entityId}/${filename}`, context)
|
||||
}
|
||||
|
||||
function getFilesTable(type, subType) {
|
||||
|
|
@ -109,7 +109,7 @@ async function getFileByFilename(context, type, subType, entityId, name) {
|
|||
}
|
||||
|
||||
async function getFileByUrl(context, url) {
|
||||
const urlPrefix = getTrustedUrl('files/', context);
|
||||
const urlPrefix = getPublicUrl('files/', context);
|
||||
if (url.startsWith(urlPrefix)) {
|
||||
const path = url.substring(urlPrefix.length);
|
||||
const pathElem = path.split('/');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue