0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Added setting to store last mention report email date (#16399)

Because there is no guarantee about a daily job running exactly once a
day, we need to store the last time that the email was sent, so that we
can refrain from sending one if it's been less than a day since the
last.

A setting has been used for this as we don't currently have a pattern
for it, we might want to consider moving this to some kind of cache
based solution in future. This has been added as a core setting so that
we don't expose it via the API.

The setting is stored as a number to allow us to store value as unix timestamp.

---------

Co-authored-by: Rishabh <zrishabhgarg@gmail.com>
This commit is contained in:
Fabien 'egg' O'Carroll 2023-03-15 17:04:41 +07:00 committed by GitHub
parent 64e5fbe5b7
commit bdaddd1a64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 3 deletions

View file

@ -0,0 +1,8 @@
const {addSetting} = require('../../utils');
module.exports = addSetting({
key: 'last_mentions_report_email_timestamp',
value: null,
type: 'number',
group: 'core'
});

View file

@ -1,5 +1,9 @@
{
"core": {
"last_mentions_report_email_timestamp": {
"defaultValue": null,
"type": "number"
},
"db_hash": {
"defaultValue": null,
"type": "string"

View file

@ -15,6 +15,7 @@ describe('Settings', function () {
// Allowlist: Only this list needs updating when a core setting is added/removed/renamed
const coreSettingKeys = [
'last_mentions_report_email_timestamp',
'db_hash',
'routes_hash',
'next_update_check',

View file

@ -5,7 +5,7 @@ const db = require('../../../core/server/data/db');
// Stuff we are testing
const models = require('../../../core/server/models');
const SETTINGS_LENGTH = 81;
const SETTINGS_LENGTH = 82;
describe('Settings Model', function () {
before(models.init);

View file

@ -236,7 +236,7 @@ describe('Exporter', function () {
// NOTE: if default settings changed either modify the settings keys blocklist or increase allowedKeysLength
// This is a reminder to think about the importer/exporter scenarios ;)
const allowedKeysLength = 73;
const allowedKeysLength = 74;
totalKeysLength.should.eql(SETTING_KEYS_BLOCKLIST.length + allowedKeysLength);
});
});

View file

@ -37,7 +37,7 @@ describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '08a9d998774843eb5594450280ab0fce';
const currentFixturesHash = 'd99d3c2891e79b8662ed6a312490d2fd';
const currentSettingsHash = 'b0c8359b7482e39112e7c5739d43f11b';
const currentSettingsHash = '7b567742b9667d38191d8455c422c5d5';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
// If this test is failing, then it is likely a change has been made that requires a DB version bump,

View file

@ -1,5 +1,9 @@
{
"core": {
"last_mentions_report_email_timestamp": {
"defaultValue": null,
"type": "string"
},
"db_hash": {
"defaultValue": null,
"type": "string"