Mailspring/packages/nylas-api/route-helpers.js

17 lines
595 B
JavaScript

const Serialization = require('./serialization');
const {PubsubConnector, MessageTypes} = require('nylas-core')
module.exports = {
createSyncbackRequest: function createSyncbackRequest(request, reply, syncRequestArgs) {
request.getAccountDatabase().then((db) => {
db.SyncbackRequest.create(syncRequestArgs).then((syncbackRequest) => {
PubsubConnector.notify({
accountId: db.accountId,
type: MessageTypes.SYNCBACK_REQUESTED,
data: syncbackRequest.id,
});
reply(Serialization.jsonStringify(syncbackRequest))
})
})
}
}