Skip to content

Commit

Permalink
Update PetStoreAssistantBot.java
Browse files Browse the repository at this point in the history
  • Loading branch information
chtrembl committed Jan 4, 2024
1 parent d3845a4 commit 95b2e84
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@ protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {

LOGGER.info("onMessageActivity: text {} id {} ", text, id);


AzurePetStoreSessionInfo azurePetStoreSessionInfo = this.sessionCache.get(id);

// strip out session id and csrf token if one was passed from soul machines
// sendTextMessage() function
AzurePetStoreSessionInfo azurePetStoreSessionInfo = PetStoreAssistantUtilities
AzurePetStoreSessionInfo incomingAzurePetStoreSessionInfo = PetStoreAssistantUtilities
.getAzurePetStoreSessionInfo(text);
if (azurePetStoreSessionInfo != null) {
text = azurePetStoreSessionInfo.getNewText();
if (incomingAzurePetStoreSessionInfo != null) {
text = incomingAzurePetStoreSessionInfo.getNewText();
//turnContext.getActivity().getId() is unique per browser over the broken recipient for some reason
this.sessionCache.put(id, azurePetStoreSessionInfo);
}
else{
azurePetStoreSessionInfo = this.sessionCache.get(id);
this.sessionCache.put(id, incomingAzurePetStoreSessionInfo);
azurePetStoreSessionInfo = incomingAzurePetStoreSessionInfo;
}

if(text.isEmpty())
Expand All @@ -106,10 +107,10 @@ protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
}

//DEBUG ONLY
if (text.contains("session"))
if (text.contains("debug"))
{
return turnContext.sendActivity(
MessageFactory.text("id:"+id)).thenApply(sendResult -> null);
MessageFactory.text("id:"+id+" sessionid"+azurePetStoreSessionInfo)).thenApply(sendResult -> null);
//return turnContext.sendActivity(
// MessageFactory.text("sender: "+turnContext.getActivity().getFrom())).thenApply(sendResult -> null);
//Set<String> keys = turnContext.getActivity().getRecipient().getProperties().keySet();
Expand Down

0 comments on commit 95b2e84

Please sign in to comment.