Skip to content

Commit

Permalink
ARM template and sign in bug fix updates (#2)
Browse files Browse the repository at this point in the history
* /Deployment
- Use S2 app service plan as default
- Changes done to avoid deployment failures while installing npm packages and executing azure functions in same service plan
/Source
- Text updates in Strings resource file
- Bug fix to enable sign in from Welcome card for 'Manage favorite' button
- Error handling to show appropriate message when user token is not available in react page
  • Loading branch information
abbodh authored Feb 5, 2020
1 parent 61414df commit ee29395
Show file tree
Hide file tree
Showing 17 changed files with 16,472 additions and 165 deletions.
2 changes: 1 addition & 1 deletion Deployment/azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"2",
"3"
],
"defaultValue": "1",
"defaultValue": "2",
"metadata": {
"description": "The size of the hosting plan (small, medium, or large)."
}
Expand Down
11 changes: 10 additions & 1 deletion Source/Microsoft.Teams.Apps.BookAThing/Bots/BookAMeetingBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ protected override async Task<TaskModuleResponse> OnTeamsTaskModuleFetchAsync(IT
return default;
}

var userToken = await this.tokenHelper.GetUserTokenAsync(activity.From.Id);
if (string.IsNullOrEmpty(userToken))
{
// No token found for user. Trying to open task module after sign out.
this.telemetryClient.TrackTrace("User token is null in OnTeamsTaskModuleFetchAsync.");
await turnContext.SendActivityAsync(Strings.SignInErrorMessage).ConfigureAwait(false);
return default;
}

var postedValues = JsonConvert.DeserializeObject<MeetingViewModel>(JObject.Parse(taskModuleRequest.Data.ToString()).SelectToken("data").ToString());
var command = postedValues.Text;
var token = this.tokenHelper.GenerateAPIAuthToken(activity.From.AadObjectId, activity.ServiceUrl, activity.From.Id, jwtExpiryMinutes: 60);
Expand Down Expand Up @@ -522,4 +531,4 @@ private TaskModuleResponse GetTaskModuleResponse(string url, string title)
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static Attachment GetFavoriteRoomsListAttachment(RoomScheduleResponse roo
Title = item.RoomName,
Subtitle = subtitle,
Type = "person",
Tap = new CardAction { Type = ActionTypes.MessageBack, DisplayText = string.Empty, Title = BotCommands.CreateMeeting, Value = JsonConvert.SerializeObject(meeting) },
Tap = new CardAction { Type = ActionTypes.MessageBack, Title = BotCommands.CreateMeeting, Value = JsonConvert.SerializeObject(meeting) },
});
}
}
Expand All @@ -110,7 +110,6 @@ public static Attachment GetFavoriteRoomsListAttachment(RoomScheduleResponse roo
Title = Strings.Refresh,
Type = ActionTypes.MessageBack,
Text = BotCommands.RefreshList,
DisplayText = string.Empty,
Value = JsonConvert.SerializeObject(new AdaptiveTaskModuleCardAction { Text = BotCommands.RefreshList, ActivityReferenceId = activityReferenceId }),
};

Expand Down
3 changes: 2 additions & 1 deletion Source/Microsoft.Teams.Apps.BookAThing/Cards/HelpCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public static List<Attachment> GetHelpAttachments()
List<CardAction> buttons = new List<CardAction>();
buttons.AddRange(new List<CardAction>
{
new CardAction(ActionTypes.MessageBack, Strings.BookRoom, text: BotCommands.BookAMeeting, displayText: Strings.BookRoom, value: string.Empty),
new CardAction(ActionTypes.MessageBack, Strings.BookRoom, text: BotCommands.BookAMeeting, displayText: Strings.BookRoom),
new TaskModuleAction(Strings.ManageFavorites, new { data = JsonConvert.SerializeObject(new AdaptiveTaskModuleCardAction { Text = BotCommands.ShowFavoriteTaskModule }) }),
});

var heroCard = new HeroCard
{
Text = Strings.SupportedCommands,
Buttons = buttons,
};

Expand Down
61 changes: 30 additions & 31 deletions Source/Microsoft.Teams.Apps.BookAThing/Cards/SuccessCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public static Attachment GetSuccessAttachment(MeetingViewModel meeting, string t
{
Type = ActionTypes.MessageBack,
Text = BotCommands.CancelMeeting,
DisplayText = string.Empty,
Value = JsonConvert.SerializeObject(new MeetingViewModel
{
MeetingId = meeting.MeetingId,
Expand All @@ -57,26 +56,26 @@ public static Attachment GetSuccessAttachment(MeetingViewModel meeting, string t
var card = new AdaptiveCard("1.0")
{
Body = new List<AdaptiveElement>
{
new AdaptiveColumnSet
{
new AdaptiveColumnSet
Columns = new List<AdaptiveColumn>
{
Columns = new List<AdaptiveColumn>
new AdaptiveColumn { Width = AdaptiveColumnWidth.Auto, Items = new List<AdaptiveElement> { new AdaptiveImage { Url = new Uri(greenBar), PixelWidth = 4 } } },
new AdaptiveColumn
{
new AdaptiveColumn { Width = AdaptiveColumnWidth.Auto, Items = new List<AdaptiveElement> { new AdaptiveImage { Url = new Uri(greenBar), PixelWidth = 4 } } },
new AdaptiveColumn
Width = AdaptiveColumnWidth.Stretch,
Items = new List<AdaptiveElement>
{
Width = AdaptiveColumnWidth.Stretch,
Items = new List<AdaptiveElement>
{
new AdaptiveTextBlock { Text = Strings.MeetingBooked, Wrap = true, Size = AdaptiveTextSize.Large, Weight = AdaptiveTextWeight.Bolder },
new AdaptiveTextBlock { Text = meeting.RoomName, Wrap = true, Spacing = AdaptiveSpacing.Small },
new AdaptiveTextBlock { Text = meeting.BuildingName, Wrap = true, Spacing = AdaptiveSpacing.Small },
new AdaptiveTextBlock { Text = dateString, Wrap = true, Spacing = AdaptiveSpacing.Small },
},
new AdaptiveTextBlock { Text = Strings.MeetingBooked, Wrap = true, Size = AdaptiveTextSize.Large, Weight = AdaptiveTextWeight.Bolder },
new AdaptiveTextBlock { Text = meeting.RoomName, Wrap = true, Spacing = AdaptiveSpacing.Small },
new AdaptiveTextBlock { Text = meeting.BuildingName, Wrap = true, Spacing = AdaptiveSpacing.Small },
new AdaptiveTextBlock { Text = dateString, Wrap = true, Spacing = AdaptiveSpacing.Small },
},
},
},
},
},
Actions = new List<AdaptiveAction>(),
};

Expand All @@ -91,37 +90,37 @@ public static Attachment GetSuccessAttachment(MeetingViewModel meeting, string t
else
{
card.Actions = new List<AdaptiveAction>
{
cancelMeetingAction,
new AdaptiveSubmitAction
{
cancelMeetingAction,
new AdaptiveSubmitAction
Title = Strings.AddFavorite,
Data = new AdaptiveSubmitActionData
{
Title = Strings.AddFavorite,
Data = new AdaptiveSubmitActionData
Msteams = new CardAction
{
Msteams = new CardAction
Type = ActionTypes.MessageBack,
Text = BotCommands.AddFavorite,
Value = JsonConvert.SerializeObject(new MeetingViewModel
{
Type = ActionTypes.MessageBack,
Text = BotCommands.AddFavorite,
DisplayText = string.Empty,
Value = JsonConvert.SerializeObject(new MeetingViewModel
{
RoomEmail = meeting.RoomEmail,
BuildingName = meeting.BuildingName,
RoomName = meeting.RoomName,
BuildingEmail = meeting.BuildingEmail,
}),
},
RoomEmail = meeting.RoomEmail,
BuildingName = meeting.BuildingName,
RoomName = meeting.RoomName,
BuildingEmail = meeting.BuildingEmail,
}),
},
},
new AdaptiveOpenUrlAction { Title = Strings.Share, Url = new Uri(meeting.WebLink) },
};
},
new AdaptiveOpenUrlAction { Title = Strings.Share, Url = new Uri(meeting.WebLink) },
};
}

var adaptiveCardAttachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card,
};

return adaptiveCardAttachment;
}
}
Expand Down
19 changes: 10 additions & 9 deletions Source/Microsoft.Teams.Apps.BookAThing/Cards/WelcomeCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ namespace Microsoft.Teams.Apps.BookAThing.Cards
using System.Collections.Generic;
using AdaptiveCards;
using Microsoft.Bot.Schema;
using Microsoft.Bot.Schema.Teams;
using Microsoft.Teams.Apps.BookAThing.Models;
using Microsoft.Teams.Apps.BookAThing.Resources;
using Newtonsoft.Json;

/// <summary>
/// Class having method to return welcome card attachment.
Expand Down Expand Up @@ -84,24 +82,26 @@ public static Attachment GetWelcomeCardAttachment(Uri welcomeCardImageUrl)
{
new AdaptiveSubmitAction
{
Title = Strings.BookRoom,
Data = new AdaptiveSubmitActionData
{
Title = Strings.BookRoom,
Data = new AdaptiveSubmitActionData
{
Msteams = new CardAction
{
Type = ActionTypes.MessageBack,
Text = BotCommands.BookAMeeting,
DisplayText = string.Empty,
Value = null,
},
},
},
},
new AdaptiveSubmitAction
{
Title = Strings.ManageFavorites,
Data = new AdaptiveSubmitActionData
{
Msteams = new TaskModuleAction(Strings.ManageFavorites, new { data = JsonConvert.SerializeObject(new AdaptiveTaskModuleCardAction { Text = BotCommands.ShowFavoriteTaskModule }) }),
Msteams = new CardAction
{
Type = ActionTypes.MessageBack,
Text = BotCommands.ManageFavorites,
},
},
},
},
Expand All @@ -112,6 +112,7 @@ public static Attachment GetWelcomeCardAttachment(Uri welcomeCardImageUrl)
ContentType = AdaptiveCard.ContentType,
Content = card,
};

return adaptiveCardAttachment;
}
}
Expand Down
Loading

0 comments on commit ee29395

Please sign in to comment.