Skip to content
This repository was archived by the owner on Jul 2, 2019. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AzureBot/Controllers/MessagesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public virtual async Task<HttpResponseMessage> Post([FromBody] Activity activity
{
if (activity != null)
{
StateClient stateClient = activity.GetStateClient();

switch (activity.GetActivityType())
{
case ActivityTypes.Event:
Expand All @@ -33,7 +35,6 @@ public virtual async Task<HttpResponseMessage> Post([FromBody] Activity activity
var token = await AuthBot.Helpers.AzureActiveDirectoryHelper.GetTokenByAuthCodeAsync(eventToken,
(Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache)tokenCache);

StateClient stateClient = activity.GetStateClient();
BotData userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id);
userData.SetProperty(ContextConstants.AuthResultKey, token);
await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData);
Expand All @@ -44,7 +45,6 @@ public virtual async Task<HttpResponseMessage> Post([FromBody] Activity activity
if (!string.IsNullOrEmpty(activity.Text) &&
new[] { "cancel", "reset", "start over", "/deleteprofile" }.Any(c => activity.Text.Contains(c)))
{
StateClient stateClient = activity.GetStateClient();
await stateClient.BotState.DeleteStateForUserAsync(activity.ChannelId,
activity.From.Id,
CancellationToken.None);
Expand Down