in cloudformationTemplates/urlPreviewForAsyncChat/js/startChatContact.js [135:165]
function updatePreviousConnectionData(previousContactId, currentContactId) {
if (previousContactId == "INITIAL_CHAT") {
return new Promise( function (resolve, reject) {
resolve("Initial chat, not updating.");
});
}
return new Promise(function (resolve, reject) {
console.log("Setting contactId (" + previousContactId + ") to have a next contact id of: " + currentContactId);
var params = {
TableName: process.env.CHAT_DATA_TABLE,
Key: {
'contactId': previousContactId
},
UpdateExpression: 'set nextContactId = :next',
ExpressionAttributeValues: {
':next' : currentContactId
}
};
docClient.update(params, function(err, results) {
if (err) {
console.error("Unable to update previous contact data. Error:", JSON.stringify(err, null, 2));
reject();
} else {
console.log("Update succeeded.");
resolve("Success!");
}
});
});
}