Skip to content

Commit

Permalink
trying an imediate empty 200 to kill timeout errors in slack
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 afa8ca6 commit e7e091b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function handler(event, context, callback) {
response_url
} = parseFormString(body);

console.log('PROCESSING SLACK COMMAND', text, response_url, SPOTIFY_RADIO_PLAYLIST)
//console.log('PROCESSING SLACK COMMAND', text, response_url, SPOTIFY_RADIO_PLAYLIST)

if (token !== SLACK_TOKEN) {
callback(null,
Expand All @@ -42,15 +42,11 @@ function handler(event, context, callback) {
extractFromUri(trackUri, 'track'),
SPOTIFY_USER_ACCESS_TOKEN
)
.catch((error) => {
console.log(error);
callback(null,
slack.slackResp(error.message)
);
})
.then((trackInfo) => {
callback(null,
slack.slackResp(radio.SLACK_PENDING_MESSAGE(trackInfo))
slack.notify(
response_url,
radio.SLACK_PENDING_MESSAGE(trackInfo),
slack.TYPE_PRIVATE
);
radio
.playBasedOnTrack(
Expand All @@ -60,22 +56,31 @@ function handler(event, context, callback) {
SPOTIFY_LOCAL_URL
)
.then((msg) => {
console.log('notify success', response_url, msg);
//console.log('notify success', response_url, msg);
slack.notify(
response_url,
msg
);
})
.catch(({ message }) => {
console.log('notify error', response_url, message);
//console.log('notify error', response_url, message);
slack.notify(
response_url,
`Error creating playlist: ${message}`,
slack.TYPE_PRIVATE
)
);
});
})
.catch((error) => {
slack.notify(
response_url,
error.message,
slack.TYPE_PRIVATE
);
});

callback(null, slack.slackResp(''));

}
}

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 e7e091b

Please sign in to comment.