mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 06:06:35 +08:00
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
const Joi = require('joi');
|
|
const {SchedulerUtils} = require(`nylas-core`);
|
|
|
|
module.exports = (server) => {
|
|
server.route({
|
|
method: 'POST',
|
|
path: '/sync-policy/{account_id}',
|
|
config: {
|
|
description: 'Set the sync policy',
|
|
notes: 'Notes go here',
|
|
tags: ['sync-policy'],
|
|
validate: {
|
|
params: {
|
|
account_id: Joi.number().integer(),
|
|
},
|
|
payload: {
|
|
sync_policy: Joi.string(),
|
|
},
|
|
},
|
|
response: {
|
|
schema: Joi.string(),
|
|
},
|
|
},
|
|
handler: (request, reply) => {
|
|
const newPolicy = JSON.parse(request.payload.sync_policy);
|
|
SchedulerUtils.assignPolicy(request.params.account_id, newPolicy)
|
|
.then(() => reply("Success"));
|
|
},
|
|
});
|
|
|
|
server.route({
|
|
method: 'POST',
|
|
path: '/sync-policy',
|
|
config: {
|
|
description: 'Set the sync policy for several accounts',
|
|
notes: 'Notes go here',
|
|
tags: ['sync-policy'],
|
|
validate: {
|
|
payload: {
|
|
sync_policy: Joi.string(),
|
|
account_ids: Joi.array().items(Joi.number().integer().min(0)),
|
|
},
|
|
},
|
|
response: {
|
|
schema: Joi.string(),
|
|
},
|
|
},
|
|
handler: (request, reply) => {
|
|
const newPolicy = JSON.parse(request.payload.sync_policy);
|
|
SchedulerUtils.assignPolicyToAcounts(request.payload.account_ids, newPolicy)
|
|
.then(() => reply("Success"));
|
|
},
|
|
})
|
|
};
|