mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-11 07:04:33 +08:00
[local-sync] make syncbackRequest objects N1-ready
This commit is contained in:
parent
b36f61812d
commit
b06566d8bd
2 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,8 @@ const Serialization = require('./serialization');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createSyncbackRequest: function createSyncbackRequest(request, reply, syncRequestArgs) {
|
createSyncbackRequest: function createSyncbackRequest(request, reply, syncRequestArgs) {
|
||||||
request.getAccountDatabase().then((db) => {
|
request.getAccountDatabase().then((db) => {
|
||||||
|
const accountId = request.auth.credentials.id;
|
||||||
|
syncRequestArgs.accountId = accountId
|
||||||
db.SyncbackRequest.create(syncRequestArgs).then((syncbackRequest) => {
|
db.SyncbackRequest.create(syncRequestArgs).then((syncbackRequest) => {
|
||||||
reply(Serialization.jsonStringify(syncbackRequest))
|
reply(Serialization.jsonStringify(syncbackRequest))
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,15 +10,18 @@ module.exports = (sequelize, Sequelize) => {
|
||||||
},
|
},
|
||||||
error: JSONType('error'),
|
error: JSONType('error'),
|
||||||
props: JSONType('props'),
|
props: JSONType('props'),
|
||||||
|
accountId: { type: Sequelize.STRING, allowNull: false },
|
||||||
}, {
|
}, {
|
||||||
instanceMethods: {
|
instanceMethods: {
|
||||||
toJSON: function toJSON() {
|
toJSON: function toJSON() {
|
||||||
return {
|
return {
|
||||||
id: `${this.id}`,
|
id: `${this.id}`,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
status: this.status,
|
error: JSON.stringify(this.error || {}),
|
||||||
error: this.error,
|
|
||||||
props: this.props,
|
props: this.props,
|
||||||
|
status: this.status,
|
||||||
|
object: 'providerSyncbackRequest',
|
||||||
|
account_id: this.accountId,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue