Work in progress on refactoring all mail sending to use the message sender an sender workers. No yet finished.
This commit is contained in:
parent
355e03900a
commit
4e9f6bd57b
22 changed files with 811 additions and 444 deletions
|
@ -15,7 +15,7 @@ const entityTypesWithFiles = {
|
|||
exports.up = (knex, Promise) => (async() => {
|
||||
await knex.schema.table('queued', table => {
|
||||
table.integer('send_configuration').unsigned().notNullable();
|
||||
table.integer('type').unsigned().notNullable(); // The values come from campaign-sender.js:MessageType
|
||||
table.integer('type').unsigned().notNullable(); // The values come from message-sender.js:MessageType
|
||||
table.text('data', 'longtext');
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
const { CampaignType, CampaignStatus } = require('../../../../shared/campaigns');
|
||||
|
||||
exports.up = (knex, Promise) => (async() => {
|
||||
await knex.schema.table('campaigns', table => {
|
||||
table.timestamp('start_at').nullable().defaultTo(null);
|
||||
});
|
||||
|
||||
await knex('campaigns')
|
||||
.whereIn('type', [CampaignType.REGULAR, CampaignType.RSS_ENTRY])
|
||||
.whereIn('status', [CampaignStatus.SCHEDULED, CampaignStatus.SENDING, CampaignStatus.PAUSING, CampaignStatus.PAUSED])
|
||||
.whereNotNull('scheduled')
|
||||
.update({
|
||||
start_at: knex.raw('scheduled')
|
||||
});
|
||||
|
||||
await knex('campaigns')
|
||||
.whereIn('type', [CampaignType.REGULAR, CampaignType.RSS_ENTRY])
|
||||
.whereIn('status', [CampaignStatus.SCHEDULED, CampaignStatus.SENDING, CampaignStatus.PAUSING, CampaignStatus.PAUSED])
|
||||
.whereNull('scheduled')
|
||||
.update({
|
||||
start_at: new Date()
|
||||
});
|
||||
})();
|
||||
|
||||
exports.down = (knex, Promise) => (async() => {
|
||||
})();
|
|
@ -0,0 +1,25 @@
|
|||
exports.up = (knex, Promise) => (async() => {
|
||||
const queued = await knex('queued');
|
||||
|
||||
for (const queuedEntry of queued) {
|
||||
const data = JSON.parse(queuedEntry.data);
|
||||
|
||||
data.listId = queuedEntry.list;
|
||||
data.subscriptionId = queuedEntry.subscription;
|
||||
|
||||
knex('queued')
|
||||
.where('id', queuedEntry.id)
|
||||
.update({
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
}
|
||||
|
||||
await knex.schema.table('queued', table => {
|
||||
table.dropColumn('list');
|
||||
table.dropColumn('subscription');
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
exports.down = (knex, Promise) => (async() => {
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue