0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Prevent an event-processing error if there is no timezone setting

refs https://github.com/TryGhost/Ghost/pull/14197

- We default to UTC when there is no setting timezone
This commit is contained in:
Thibaut Patel 2022-03-02 11:10:36 +01:00 committed by Thibaut Patel
parent 527ef79955
commit 91d5fa0fc5

View file

@ -88,7 +88,13 @@ class GhostEventProcessor extends EventProcessor {
opened_at: this.db.knex.raw('COALESCE(opened_at, ?)', [moment.utc(event.timestamp).format('YYYY-MM-DD HH:mm:ss')]) opened_at: this.db.knex.raw('COALESCE(opened_at, ?)', [moment.utc(event.timestamp).format('YYYY-MM-DD HH:mm:ss')])
}); });
const {value: timezone} = await this.db.knex('settings').first('value').where('key', 'timezone'); // Using the default timezone set in https://github.com/TryGhost/Ghost/blob/2c5643623db0fc4db390f6997c81a73dca7ccacd/core/server/data/schema/default-settings/default-settings.json#L105
let timezone = 'Etc/UTC';
const timezoneData = await this.db.knex('settings').first('value').where('key', 'timezone');
if (timezoneData && timezoneData.value) {
timezone = timezoneData.value;
}
await this.db.knex('members') await this.db.knex('members')
.where('email', '=', event.recipientEmail) .where('email', '=', event.recipientEmail)
.andWhere(builder => builder .andWhere(builder => builder