Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/actions/zones.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

function simplifyPlayer(player) {
if (typeof player === 'undefined') {
return {};
}
return {
uuid: player.uuid,
state: player.state,
Expand All @@ -13,6 +16,9 @@ function simplifyPlayer(player) {

function simplifyZones(zones) {
return zones.map((zone) => {
if (typeof zone === 'undefined') {
return {};
}
return {
uuid: zone.uuid,
coordinator: simplifyPlayer(zone.coordinator),
Expand All @@ -27,4 +33,4 @@ function zones(player) {

module.exports = function (api) {
api.registerAction('zones', zones);
}
}
7 changes: 6 additions & 1 deletion lib/sonos-http-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function HttpAPI(discovery, settings) {
}

const params = req.url.substring(1).split('/');

// parse decode player name considering decode errors
let player;
try {
Expand All @@ -81,6 +81,11 @@ function HttpAPI(discovery, settings) {
opt.values = params.splice(1);
}

if (!player) {
return sendResponse(500, { status: 'error', error: 'Sonos system is busy.' });
}


function sendResponse(code, body) {
var jsonResponse = JSON.stringify(body);
res.statusCode = code;
Expand Down
Loading