Skip to content

Commit

Permalink
returning the callback on success
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwards, Chris authored and Edwards, Chris committed Aug 15, 2017
1 parent 2c53f50 commit bc5c25c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ function handler(event, context, callback) {
extractFromUri(trackUri, 'track'),
SPOTIFY_USER_ACCESS_TOKEN
)
.catch((error) => {
callback(null, slack.slackResp(
error.message, 200, slack.TYPE_PRIVATE
));
})
.then((trackInfo) => {
slack.notify(
response_url,
radio.SLACK_PENDING_MESSAGE(trackInfo)
);
radio
.playBasedOnTrack(
SPOTIFY_RADIO_PLAYLIST,
Expand All @@ -70,12 +69,18 @@ function handler(event, context, callback) {
slack.TYPE_PRIVATE
);
});
// eslint-disable-next-line no-param-reassign
context.callbackWaitsForEmptyEventLoop = false;
callback(null, slack.slackResp(
radio.SLACK_PENDING_MESSAGE(trackInfo)
));
})
.catch((error) => {
slack.notify(
response_url,
error.message,
slack.TYPE_PRIVATE
);
});
// eslint-disable-next-line no-param-reassign
context.callbackWaitsForEmptyEventLoop = false;
return callback(null, slack.slackResp(''));

}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion test/test_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('The Index Lambda Handler', () => {
artist: 'Cardi B',
id: '2771LMNxwf62FTAdpJMQfM'
};
const respMsg = radio.SLACK_PENDING_MESSAGE(trackInfo);
const respMsg = ''; //radio.SLACK_PENDING_MESSAGE(trackInfo);

beforeEach(() => {
sinon
Expand Down

0 comments on commit bc5c25c

Please sign in to comment.