Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function fileMigrateHandler(uid, data, code, message, req, newDc) {
req.dc = Just(newDc)
// const futureAuth = Config.authRequest.get(uid, newDc)
if (!alreadyMoved) {
// Config.halt.set(uid, newDc, true)
const auth = cache(
moveAuthProgression(uid, newDc)
// .map(tapLog`after auth`)
// .map(resp => (Config.halt.set(uid, newDc, false), resp))
// .map(e => (log`auth`(e), e))
)
// const authReq = invoke(uid, 'auth.exportAuthorization', { dc_id: newDc })
// .map(resp => (console.log(resp), resp))
// // .map(({ id, bytes }) => ({ id, bytes }))
// // .map(tapLog`before auth`)
// .chain(resp => {
// const { id, bytes } = exportAuthRefine(resp)
// const refined = { id, bytes: [...bytes] }
// const futureAuth = Config.authRequest.get(uid, newDc)
// if (futureAuth) return futureAuth
// // const auth = cache(Auth(uid, newDc)
// // .map(tapLog`after auth`)
const req: typeof runThread = savedReq
return req
}
const runThread = getUrl(uid, dc)
.chain(url => authFuture(uid, dc, url))
.map(res => ({ ...res, uid }))
.chain(res => encaseP(async res => {
const setter = Config.storageAdapter.set
await setter.salt(uid, dc, res.serverSalt)
await setter.authKey(uid, dc, res.authKey)
await setter.authID(uid, dc, res.authKeyID)
return res
}, res))
.map(res => (dispatch(MAIN.AUTH.RESOLVE(res), uid), res))
const future = cache(runThread)
Config.authRequest.set(uid, dc, future)
return future
}
get pending(): Promise {
if (!this.currentRequest)
this.currentRequest = cache(futureRequest(this.thread, this.maxWait)
.map(x => {
delete this.currentRequest
this.thread.checkLongPoll()
this.pending
}))
return this.currentRequest.promise()
}