Skip to content

Commit

Permalink
Fix linting errors in the broker
Browse files Browse the repository at this point in the history
  • Loading branch information
raar1 committed Nov 8, 2022
1 parent 70d2e6a commit 2853e81
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions niceday-broker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ function requestRasa(text, userId, attachmentIds, callback) {
xhr.open('POST', RASA_AGENT_URL, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = callback;
const data = JSON.stringify({ sender: userId, message: text, metadata: {'attachmentIds': attachmentIds} });
const data = JSON.stringify({
sender: userId,
message: text,
metadata: { attachmentIds },
});
xhr.send(data);
}

Expand Down Expand Up @@ -54,14 +58,14 @@ function onRasaResponse() {
if (ENVIRONMENT === 'prod') {
await sleep(i * MESSAGE_DELAY);
}
var attachment = {
const attachment = {
replyOfId: null,
attachmentIds: []
}
if(message.hasOwnProperty('metadata')){
attachment.attachmentIds = message.metadata
attachmentIds: [],
};
if (message.hasOwn('metadata')) {
attachment.attachmentIds = message.metadata;
}
sendMessage(message.text, parseInt(message.recipient_id, 10),attachment);
sendMessage(message.text, parseInt(message.recipient_id, 10), attachment);
});
} else if (this.readyState === 4) {
console.log('Something went wrong, status:', this.status, this.responseText);
Expand All @@ -85,7 +89,6 @@ class MessageHandler {
}
}


function setup(therapistId, token) {
// Setup connection
chatSdk.init(SenseServerEnvironment.Alpha);
Expand Down

0 comments on commit 2853e81

Please sign in to comment.