Merge pull request #439 from shocknet/fix/init-currentStreamInfo

init current stream info
This commit is contained in:
CapDog 2021-07-24 14:17:37 -04:00 committed by GitHub
commit 1d1a342d6a
2 changed files with 27 additions and 3 deletions

View file

@ -613,6 +613,7 @@ const register = async (alias, pass) => {
await API.Actions.setBio('A little bit about myself.', user)
await API.Actions.setDefaultSeedProvider('', user)
await API.Actions.setSeedServiceData('', user)
await API.Actions.setCurrentStreamInfo('', user)
return pub
})
}

View file

@ -218,8 +218,7 @@ const setDefaultSeedProvider = (encryptedSeedProvider, user) =>
/**
* @param {string} encryptedSeedServiceData
* @param {UserGUNNode} user
* @throws {TypeError} Rejects if displayName is not an string or an empty
* string.
* @throws {TypeError}
* @returns {Promise<void>}
*/
const setSeedServiceData = (encryptedSeedServiceData, user) =>
@ -239,6 +238,29 @@ const setSeedServiceData = (encryptedSeedServiceData, user) =>
}
})
})
/**
* @param {string} encryptedCurrentStreamInfo
* @param {UserGUNNode} user
* @throws {TypeError}
* @returns {Promise<void>}
*/
const setCurrentStreamInfo = (encryptedCurrentStreamInfo, user) =>
new Promise((resolve, reject) => {
if (!user.is) {
throw new Error(ErrorCode.NOT_AUTH)
}
if (typeof encryptedCurrentStreamInfo !== 'string') {
throw new TypeError()
}
user.get('currentStreamInfo').put(encryptedCurrentStreamInfo, ack => {
if (ack.err && typeof ack.err !== 'number') {
reject(new Error(ack.err))
} else {
resolve()
}
})
})
/**
* @typedef {object} SpontPaymentOptions
@ -909,5 +931,6 @@ module.exports = {
sendSpontaneousPayment,
createPostNew,
setDefaultSeedProvider,
setSeedServiceData
setSeedServiceData,
setCurrentStreamInfo
}