MCPcopy
hub / github.com/openstf/stf / updateDeviceOriginGroup

Function updateDeviceOriginGroup

lib/units/api/controllers/devices.js:333–354  ·  view source on GitHub ↗
(group, serial)

Source from the content-addressed store, hash-verified

331 }
332
333 function updateDeviceOriginGroup(group, serial) {
334 const lock = {}
335
336 return dbapi.lockDeviceByOrigin(req.user.groups.subscribed, serial).then(function(stats) {
337 if (!stats.replaced) {
338 return apiutil.lightComputeStats(res, stats)
339 }
340 lock.device = stats.changes[0].new_val
341
342 return dbapi.isUpdateDeviceOriginGroupAllowed(serial, group)
343 .then(function(updatingAllowed) {
344 if (!updatingAllowed) {
345 apiutil.respond(res, 403, 'Forbidden (device is currently booked)')
346 return Promise.reject('booked')
347 }
348 return askUpdateDeviceOriginGroup(group, serial)
349 })
350 })
351 .finally(function() {
352 lockutil.unlockDevice(lock)
353 })
354 }
355
356 function updateDevicesOriginGroup(group, serials) {
357 let results = []

Callers 1

updateDevicesOriginGroupFunction · 0.85

Calls 1

Tested by

no test coverage detected