[local-sync] make syncbackRequest objects N1-ready

This commit is contained in:
Evan Morikawa 2016-12-02 16:14:30 -05:00
parent b36f61812d
commit b06566d8bd
2 changed files with 7 additions and 2 deletions

View file

@ -3,6 +3,8 @@ const Serialization = require('./serialization');
module.exports = {
createSyncbackRequest: function createSyncbackRequest(request, reply, syncRequestArgs) {
request.getAccountDatabase().then((db) => {
const accountId = request.auth.credentials.id;
syncRequestArgs.accountId = accountId
db.SyncbackRequest.create(syncRequestArgs).then((syncbackRequest) => {
reply(Serialization.jsonStringify(syncbackRequest))
})

View file

@ -10,15 +10,18 @@ module.exports = (sequelize, Sequelize) => {
},
error: JSONType('error'),
props: JSONType('props'),
accountId: { type: Sequelize.STRING, allowNull: false },
}, {
instanceMethods: {
toJSON: function toJSON() {
return {
id: `${this.id}`,
type: this.type,
status: this.status,
error: this.error,
error: JSON.stringify(this.error || {}),
props: this.props,
status: this.status,
object: 'providerSyncbackRequest',
account_id: this.accountId,
}
},
},