@oddnetworks/oddworks
Advanced tools
Comparing version 4.3.6 to 4.4.0
@@ -111,2 +111,4 @@ # Resources | ||
- __duration__ Integer - the duration of the video in milliseconds. Default: `0` | ||
- __position__ Integer - the position of the video in milliseconds for the requesting [Viewer](#viewer). Default: `0` | ||
- __complete__ Boolean - mark the video as completely watched for the requesting [Viewer](#viewer). Default: `false` | ||
- __genres__ Array - contains a string of genres. | ||
@@ -140,2 +142,4 @@ - __cast__ Array - contains [Cast](#cast) objects. | ||
This resource is used to update [Video](#video) progress based on a [Viewer](#viewer) and is not exposed through the API other than to `POST` progress data. | ||
__Type:__ `progress` | ||
@@ -146,4 +150,2 @@ | ||
- __channel__ String | ||
- __viewer__ String | ||
- __video__ String | ||
- __position__ Integer - the current position of the viewer's progress on the video. Default: `0` | ||
@@ -150,0 +152,0 @@ - __complete__ Boolean - has the viewer completed watching the video. Default: `false` |
@@ -59,2 +59,3 @@ 'use strict'; | ||
case 'PATCH': | ||
case 'DELETE': | ||
try { | ||
@@ -61,0 +62,0 @@ req.body = validateUpdate(req.body.data); |
@@ -21,2 +21,3 @@ 'use strict'; | ||
const viewer = req.identity.viewer; | ||
let channel; | ||
@@ -30,3 +31,5 @@ if (!platform && !this.isAdminRequest(req)) { | ||
return this.getChannel(req) | ||
.then(channel => { | ||
.then(chan => { | ||
channel = chan; | ||
const args = {type, id}; | ||
@@ -57,2 +60,34 @@ | ||
res.body = resource; | ||
let progressPromise = Promise.resolve(false); | ||
if (viewer && resource.type === 'video') { | ||
progressPromise = this.bus.query({role: 'store', cmd: 'get', type: 'progress'}, {id: `${resource.id}:${viewer.id}`, type: 'progress', channel: channel.id}); | ||
} | ||
return progressPromise; | ||
}) | ||
.then(progress => { | ||
if (progress) { | ||
res.body.position = progress.position || 0; | ||
res.body.complete = progress.complete || false; | ||
} | ||
let includePromise = Promise.resolve(); | ||
if (res.body.included) { | ||
includePromise = Promise.map(res.body.included, resource => { | ||
return this.bus.query({role: 'store', cmd: 'get', type: 'progress'}, {id: `${resource.id}:${viewer.id}`, type: 'progress', channel: channel.id}) | ||
.then(progress => { | ||
if (progress) { | ||
resource.position = progress.position || 0; | ||
resource.complete = progress.complete || false; | ||
} | ||
return resource; | ||
}); | ||
}); | ||
} | ||
return includePromise; | ||
}) | ||
.then(() => { | ||
res.status(200); | ||
@@ -59,0 +94,0 @@ next(); |
@@ -15,4 +15,3 @@ 'use strict'; | ||
const CatalogSearchController = require('./controllers/catalog-search-controller'); | ||
const CatalogProgressListController = require('./controllers/catalog-progress-list-controller'); | ||
const CatalogProgressItemController = require('./controllers/catalog-progress-item-controller'); | ||
const CatalogProgressController = require('./controllers/catalog-progress-controller'); | ||
@@ -37,3 +36,4 @@ module.exports = function (bus, options) { | ||
CatalogSpecListController, | ||
CatalogSearchController | ||
CatalogSearchController, | ||
CatalogProgressController | ||
}; | ||
@@ -156,20 +156,10 @@ | ||
router.all( | ||
`/progress`, | ||
`/videos/:id/progress`, | ||
middleware['request-authorize']({bus, audience: { | ||
post: ['admin', 'platform'] | ||
}}), | ||
CatalogProgressListController.create({bus, type: 'progress'}) | ||
CatalogProgressController.create({bus}) | ||
); | ||
router.all( | ||
`/progress/:id`, | ||
middleware['request-authorize']({bus, audience: { | ||
get: ['admin', 'platform'], | ||
patch: ['admin', 'platform'], | ||
delete: ['admin', 'platform'] | ||
}}), | ||
CatalogProgressItemController.create({bus, type: 'progress'}) | ||
); | ||
router.all( | ||
'/search', | ||
@@ -176,0 +166,0 @@ middleware['request-authorize']({bus, audience: { |
@@ -20,5 +20,8 @@ 'use strict'; | ||
const args = {type, id}; | ||
let channel; | ||
return this.getChannel(req) | ||
.then(channel => { | ||
.then(chan => { | ||
channel = chan; | ||
args.channel = channel.id; | ||
@@ -38,2 +41,21 @@ | ||
res.body = resource; | ||
let includePromise = Promise.resolve(); | ||
if (res.body.included) { | ||
includePromise = Promise.map(res.body.included, resource => { | ||
return this.bus.query({role: 'store', cmd: 'get', type: 'progress'}, {id: `${res.body.id}:${resource.id}`, type: 'progress', channel: channel.id}) | ||
.then(progress => { | ||
if (progress) { | ||
resource.position = progress.position || 0; | ||
resource.complete = progress.complete || false; | ||
} | ||
return resource; | ||
}); | ||
}); | ||
} | ||
return includePromise; | ||
}) | ||
.then(() => { | ||
res.status(200); | ||
@@ -40,0 +62,0 @@ next(); |
{ | ||
"name": "@oddnetworks/oddworks", | ||
"version": "4.3.6", | ||
"version": "4.4.0", | ||
"description": "An extensible media platform for OTT devices.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/oddworks.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
200063
4423
68
4