Refresh remote accounts

This commit is contained in:
Chocobozzz 2018-01-04 14:04:02 +01:00
parent 4cb6d45788
commit a5625b4167
No known key found for this signature in database
GPG key ID: 583A612D890159BE
7 changed files with 121 additions and 60 deletions

View file

@ -1,5 +1,6 @@
import * as retry from 'async/retry'
import * as Bluebird from 'bluebird'
import { Model } from 'sequelize-typescript'
import { logger } from './logger'
type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] }
@ -34,9 +35,18 @@ function transactionRetryer <T> (func: (err: any, data: T) => any) {
})
}
function updateInstanceWithAnother <T> (instanceToUpdate: Model<T>, baseInstance: Model<T>) {
const obj = baseInstance.toJSON()
for (const key of Object.keys(obj)) {
instanceToUpdate.set(key, obj[key])
}
}
// ---------------------------------------------------------------------------
export {
retryTransactionWrapper,
transactionRetryer
transactionRetryer,
updateInstanceWithAnother
}