Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
Fix Returns from webpage (#235)
Browse files Browse the repository at this point in the history
* Fix Returns from webpage
  • Loading branch information
tamarahills committed Mar 4, 2019
1 parent adb5f09 commit b411931
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions command/CommandController.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ router.post('/webpage', VerifyToken, async function(req, res) {
logger.debug('summary is: ' + summ);

try {
let version = req.body.v ? req.body.v : 1;
let version = 1;
logger.debug('/webpage version is: ' + version);

logger.debug(req.body);
Expand All @@ -332,7 +332,14 @@ router.post('/webpage', VerifyToken, async function(req, res) {
mobileMetadata,
version
);
mData.audio_url = response.url;
// Cleanup the old snake_case... TODO: SEE IF WE CAN REMOVE
// WITHOUT AFFECTING ALEXA.
mData['audioUrl'] = response.url;
delete mData.length_minutes;
delete mData.image_url;
mData['iconUrl'] = mData.icon_url;
delete mData.icon_url;

res.status(200).send(JSON.stringify(mData));
} else {
logger.debug('This article is not cached');
Expand Down Expand Up @@ -375,7 +382,6 @@ router.post('/webpage', VerifyToken, async function(req, res) {
// Add the correct voice:
audioMetadata['voice'] = voice.main;

logger.debug('Calling StoreMobileLocation: ' + audioMetadata.url);
await audioHelper.storeMobileLocation(
article.resolved_id,
article.lang,
Expand All @@ -395,12 +401,17 @@ router.post('/webpage', VerifyToken, async function(req, res) {
? constants.strings.TYPE_SUMMARY
: constants.strings.TYPE_MOBILE
);
logger.debug('mobilemetadata is: ' + mobileMetadata);
let response = await buildPocketResponseFromMetadata(
mobileMetadata,
version
);
mData.audio_url = response.url;
// Cleanup the old snake_case... TODO: SEE IF WE CAN REMOVE
// WITHOUT AFFECTING ALEXA.
mData['audioUrl'] = response.url;
delete mData.length_minutes;
delete mData.image_url;
mData['iconUrl'] = mData.icon_url;
delete mData.icon_url;

// Send it back to the mobile as quick as possible.
res.status(200).send(JSON.stringify(mData));
Expand Down

0 comments on commit b411931

Please sign in to comment.