Mailspring/packages/local-sync/local-sync-dashboard/routes/account.js
2016-11-22 15:34:00 -08:00

30 lines
816 B
JavaScript

const Joi = require('joi');
const {DatabaseConnector} = require(`nylas-core`);
module.exports = (server) => {
server.route({
method: 'PUT',
path: '/accounts/{accountId}/clear-sync-error',
config: {
description: 'Clears the sync error for the given account',
notes: 'Notes go here',
tags: ['accounts', 'sync-error'],
validate: {
params: {
accountId: Joi.number().integer(),
},
},
response: {
schema: Joi.string(),
},
},
handler: (request, reply) => {
DatabaseConnector.forShared().then(({Account}) => {
Account.find({where: {id: request.params.accountId}}).then((account) => {
account.syncError = null;
account.save().then(() => reply("Success"));
})
})
},
});
};