no stream seed
This commit is contained in:
parent
7eab318cc6
commit
03b50f2215
3 changed files with 3 additions and 56 deletions
|
|
@ -1115,7 +1115,6 @@ const sendSpontaneousPayment = async (
|
||||||
(opts.type !== 'contentReveal' &&
|
(opts.type !== 'contentReveal' &&
|
||||||
opts.type !== 'torrentSeed' &&
|
opts.type !== 'torrentSeed' &&
|
||||||
opts.type !== 'service' &&
|
opts.type !== 'service' &&
|
||||||
opts.type !== 'streamSeed' &&
|
|
||||||
opts.type !== 'product') ||
|
opts.type !== 'product') ||
|
||||||
!orderResponse.ackNode
|
!orderResponse.ackNode
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
/**
|
/**
|
||||||
* @type {{ seedUrl: string, seedToken: string }|null}
|
* @type {{ seedUrl: string, seedToken: string }|null}
|
||||||
*/
|
*/
|
||||||
let serviceOrderContentSeedInfo = null //in case the service is of type 'torrentSeed' or 'streamSeed' this is {seedUrl,seedToken}, can be omitted, in that case, it will be taken from env
|
let serviceOrderContentSeedInfo = null //in case the service is of type 'torrentSeed' this is {seedUrl,seedToken}, can be omitted, in that case, it will be taken from env
|
||||||
if (order.targetType === 'service') {
|
if (order.targetType === 'service') {
|
||||||
console.log('General Service')
|
console.log('General Service')
|
||||||
const { ackInfo: serviceID } = order
|
const { ackInfo: serviceID } = order
|
||||||
|
|
@ -191,7 +191,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
`service price mismatch ${amount} : ${servicePrice}`
|
`service price mismatch ${amount} : ${servicePrice}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (serviceType === 'torrentSeed' || serviceType === 'streamSeed') {
|
if (serviceType === 'torrentSeed') {
|
||||||
if (encSeedUrl && encSeedToken) {
|
if (encSeedUrl && encSeedToken) {
|
||||||
const seedUrl = await SEA.decrypt(encSeedUrl, mySecret)
|
const seedUrl = await SEA.decrypt(encSeedUrl, mySecret)
|
||||||
const seedToken = await SEA.decrypt(encSeedToken, mySecret)
|
const seedToken = await SEA.decrypt(encSeedToken, mySecret)
|
||||||
|
|
@ -425,57 +425,6 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
orderMetadata = JSON.stringify(serviceResponse)
|
orderMetadata = JSON.stringify(serviceResponse)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'streamSeed': {
|
|
||||||
console.log('STREAM')
|
|
||||||
const numberOfTokens = 1
|
|
||||||
const seedInfo = selfContentToken() //TODO this must change for streams
|
|
||||||
if (!seedInfo && !serviceOrderContentSeedInfo) {
|
|
||||||
breakError = 'torrentSeed service not available'
|
|
||||||
break //service not available
|
|
||||||
}
|
|
||||||
const seedInfoReady = serviceOrderContentSeedInfo || seedInfo
|
|
||||||
if (!seedInfoReady) {
|
|
||||||
breakError = 'torrentSeed service not available'
|
|
||||||
break //service not available
|
|
||||||
}
|
|
||||||
const { seedUrl } = seedInfoReady
|
|
||||||
const tokens = await enrollContentTokens(
|
|
||||||
numberOfTokens,
|
|
||||||
seedInfoReady
|
|
||||||
)
|
|
||||||
console.log('RES SEED OK')
|
|
||||||
const ackData = {
|
|
||||||
seedUrl,
|
|
||||||
tokens,
|
|
||||||
ackInfo
|
|
||||||
}
|
|
||||||
const toSend = JSON.stringify(ackData)
|
|
||||||
const encrypted = await SEA.encrypt(toSend, secret)
|
|
||||||
const serviceResponse = {
|
|
||||||
type: 'orderAck',
|
|
||||||
response: encrypted
|
|
||||||
}
|
|
||||||
console.log('RES SEED SENT')
|
|
||||||
await new Promise((res, rej) => {
|
|
||||||
getUser()
|
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
|
||||||
.get(ackNode)
|
|
||||||
.put(serviceResponse, ack => {
|
|
||||||
if (ack.err && typeof ack.err !== 'number') {
|
|
||||||
rej(
|
|
||||||
new Error(
|
|
||||||
`Error saving encrypted orderAck to order to response usergraph: ${ack}`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
res(null)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
console.log('RES SENT SEED')
|
|
||||||
orderMetadata = JSON.stringify(serviceResponse)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'other': //not implemented yet but save them as a coordinate anyways
|
case 'other': //not implemented yet but save them as a coordinate anyways
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -1303,7 +1303,6 @@ module.exports = async (
|
||||||
type !== 'spontaneousPayment' &&
|
type !== 'spontaneousPayment' &&
|
||||||
type !== 'tip' &&
|
type !== 'tip' &&
|
||||||
type !== 'torrentSeed' &&
|
type !== 'torrentSeed' &&
|
||||||
type !== 'streamSeed' &&
|
|
||||||
type !== 'contentReveal' &&
|
type !== 'contentReveal' &&
|
||||||
type !== 'service' &&
|
type !== 'service' &&
|
||||||
type !== 'product' &&
|
type !== 'product' &&
|
||||||
|
|
@ -1311,7 +1310,7 @@ module.exports = async (
|
||||||
) {
|
) {
|
||||||
return res.status(415).json({
|
return res.status(415).json({
|
||||||
field: 'type',
|
field: 'type',
|
||||||
errorMessage: `Only 'spontaneousPayment'| 'tip' | 'torrentSeed' | 'contentReveal' | 'service' | 'streamSeed' | 'product' |'other' payments supported via this endpoint for now.`
|
errorMessage: `Only 'spontaneousPayment'| 'tip' | 'torrentSeed' | 'contentReveal' | 'service' | 'product' |'other' payments supported via this endpoint for now.`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue