Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ private async Task OnAdaptiveCardSubmitInPersonalChatAsync(IMessageActivity mess
var userDetails = await this.GetUserDetailsInPersonalChatAsync(turnContext, cancellationToken);

newTicket = await this.CreateTicketAsync(message, askAnExpertPayload, userDetails);
smeTeamCard = new SmeTicketCard(newTicket).ToAttachment(message.LocalTimestamp);
userCard = new UserNotificationCard(newTicket).ToAttachment(Resource.NotificationCardContent, message.LocalTimestamp);
smeTeamCard = new SmeTicketCard(newTicket).ToAttachment();
userCard = new UserNotificationCard(newTicket).ToAttachment(Resource.NotificationCardContent);
break;
}

Expand Down Expand Up @@ -464,7 +464,7 @@ private async Task OnAdaptiveCardSubmitInChannelAsync(IMessageActivity message,
{
Id = ticket.SmeCardActivityId,
Conversation = new ConversationAccount { Id = ticket.SmeThreadConversationId },
Attachments = new List<Attachment> { new SmeTicketCard(ticket).ToAttachment(message.LocalTimestamp) },
Attachments = new List<Attachment> { new SmeTicketCard(ticket).ToAttachment() },
};
var updateResponse = await turnContext.UpdateActivityAsync(updateCardActivity, cancellationToken);
this.telemetryClient.TrackTrace($"Card for ticket {ticket.TicketId} updated to status ({ticket.Status}, {ticket.AssignedToObjectId}), activityId = {updateResponse.Id}");
Expand All @@ -477,21 +477,21 @@ private async Task OnAdaptiveCardSubmitInChannelAsync(IMessageActivity message,
case ChangeTicketStatusPayload.ReopenAction:
smeNotification = string.Format(Resource.SMEOpenedStatus, message.From.Name);

userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.ReopenedTicketUserNotification, message.LocalTimestamp));
userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.ReopenedTicketUserNotification));
userNotification.Summary = Resource.ReopenedTicketUserNotification;
break;

case ChangeTicketStatusPayload.CloseAction:
smeNotification = string.Format(Resource.SMEClosedStatus, ticket.LastModifiedByName);

userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.ClosedTicketUserNotification, message.LocalTimestamp));
userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.ClosedTicketUserNotification));
userNotification.Summary = Resource.ClosedTicketUserNotification;
break;

case ChangeTicketStatusPayload.AssignToSelfAction:
smeNotification = string.Format(Resource.SMEAssignedStatus, ticket.AssignedToName);

userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.AssignedTicketUserNotification, message.LocalTimestamp));
userNotification = MessageFactory.Attachment(new UserNotificationCard(ticket).ToAttachment(Resource.AssignedTicketUserNotification));
userNotification.Summary = Resource.AssignedTicketUserNotification;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public async Task<MessagingExtensionResult> GetSearchResultAsync(string query, s
};

var selectedTicketAdaptiveCard = new MessagingExtensionTicketsCard(ticket);
composeExtensionResult.Attachments.Add(selectedTicketAdaptiveCard.ToAttachment(localTimestamp).ToMessagingExtensionAttachment(previewCard.ToAttachment()));
composeExtensionResult.Attachments.Add(selectedTicketAdaptiveCard.ToAttachment().ToMessagingExtensionAttachment(previewCard.ToAttachment()));
}

return composeExtensionResult;
Expand Down
14 changes: 10 additions & 4 deletions Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/CardHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,17 @@ public static string GetTicketDisplayStatusForSme(TicketEntity ticket)
/// <param name="dateTime">The date and time to format.</param>
/// <param name="userLocalTime">The sender's local time, as determined by the local timestamp of the activity.</param>
/// <returns>A datetime string.</returns>
public static string GetFormattedDateInUserTimeZone(DateTime dateTime, DateTimeOffset? userLocalTime)
public static string GetFormattedDateInUserTimeZone(DateTime dateTime, DateTimeOffset? userLocalTime = null)
{
// Adaptive card on mobile has a bug where it does not support DATE and TIME, so for now we convert the date and time manually
// TODO: Change to use DATE() function
return dateTime.Add(userLocalTime?.Offset ?? TimeSpan.FromMinutes(0)).ToShortDateString();
if (userLocalTime == null)
{
var timestamp = dateTime.ToString("yyyy-MM-ddTHH:mm:ssZ");
return "{{DATE(" + timestamp + ", SHORT)}}";
}
else
{
return dateTime.Add(userLocalTime?.Offset ?? TimeSpan.FromMinutes(0)).ToShortDateString();
}
}
}
}
10 changes: 4 additions & 6 deletions Source/Microsoft.Teams.Apps.FAQPlusPlus/Cards/SmeTicketCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ public SmeTicketCard(TicketEntity ticket)
/// <summary>
/// Returns an attachment based on the state and information of the ticket.
/// </summary>
/// <param name="localTimestamp">Local timestamp of the user activity.</param>
/// <returns>Returns the attachment that will be sent in a message.</returns>
public Attachment ToAttachment(DateTimeOffset? localTimestamp)
public Attachment ToAttachment()
{
var card = new AdaptiveCard("1.0")
{
Expand All @@ -59,7 +58,7 @@ public Attachment ToAttachment(DateTimeOffset? localTimestamp)
},
new AdaptiveFactSet
{
Facts = this.BuildFactSet(localTimestamp),
Facts = this.BuildFactSet(),
},
},
Actions = this.BuildActions(),
Expand Down Expand Up @@ -142,9 +141,8 @@ protected AdaptiveAction CreateChatWithUserAction()
/// <summary>
/// Return the appropriate fact set based on the state and information in the ticket.
/// </summary>
/// <param name="localTimestamp">The current timestamp.</param>
/// <returns>The fact set showing the necessary details.</returns>
private List<AdaptiveFact> BuildFactSet(DateTimeOffset? localTimestamp)
private List<AdaptiveFact> BuildFactSet()
{
List<AdaptiveFact> factList = new List<AdaptiveFact>();

Expand Down Expand Up @@ -177,7 +175,7 @@ private List<AdaptiveFact> BuildFactSet(DateTimeOffset? localTimestamp)
factList.Add(new AdaptiveFact
{
Title = Resource.ClosedFactTitle,
Value = CardHelper.GetFormattedDateInUserTimeZone(this.Ticket.DateClosed.Value, localTimestamp),
Value = CardHelper.GetFormattedDateInUserTimeZone(this.Ticket.DateClosed.Value),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ public UserNotificationCard(TicketEntity ticket)
/// Returns a user notification card for the ticket.
/// </summary>
/// <param name="message">The status message to add to the card</param>
/// <param name="activityLocalTimestamp">Local time stamp of user activity.</param>
/// <returns>An adaptive card as an attachment</returns>
public Attachment ToAttachment(string message, DateTimeOffset? activityLocalTimestamp)
public Attachment ToAttachment(string message)
{
var card = new AdaptiveCard("1.0")
{
Expand All @@ -47,7 +46,7 @@ public Attachment ToAttachment(string message, DateTimeOffset? activityLocalTime
},
new AdaptiveFactSet
{
Facts = this.BuildFactSet(this.ticket, activityLocalTimestamp)
Facts = this.BuildFactSet(this.ticket)
},
},
Actions = this.BuildActions(this.ticket),
Expand Down Expand Up @@ -94,9 +93,8 @@ private List<AdaptiveAction> BuildActions(TicketEntity ticket)
/// Building the fact set to render out the user facing details.
/// </summary>
/// <param name="ticket">The current ticket information.</param>
/// <param name="activityLocalTimestamp">The local timestamp.</param>
/// <returns>The adaptive facts.</returns>
private List<AdaptiveFact> BuildFactSet(TicketEntity ticket, DateTimeOffset? activityLocalTimestamp)
private List<AdaptiveFact> BuildFactSet(TicketEntity ticket)
{
List<AdaptiveFact> factList = new List<AdaptiveFact>();
factList.Add(new AdaptiveFact
Expand All @@ -123,15 +121,15 @@ private List<AdaptiveFact> BuildFactSet(TicketEntity ticket, DateTimeOffset? act
factList.Add(new AdaptiveFact
{
Title = Resource.DateCreatedDisplayFactTitle,
Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateCreated, activityLocalTimestamp),
Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateCreated),
});

if (ticket.Status == (int)TicketState.Closed)
{
factList.Add(new AdaptiveFact
{
Title = Resource.ClosedFactTitle,
Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateClosed.Value, activityLocalTimestamp),
Value = CardHelper.GetFormattedDateInUserTimeZone(this.ticket.DateClosed.Value),
});
}

Expand Down