Skip to content

Commit

Permalink
[Email] Add delete email info confirm (microsoft#498)
Browse files Browse the repository at this point in the history
* add delete email info confirm

* enable show email
  • Loading branch information
DingmaomaoBJTU authored Dec 27, 2018
1 parent 06cba38 commit e0aa783
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using EmailSkill.Dialogs.DeleteEmail.Resources;
using EmailSkill.Dialogs.Shared.Resources;
using EmailSkill.Dialogs.Shared.Resources.Strings;
using EmailSkill.Util;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Solutions.Extensions;
Expand Down Expand Up @@ -64,10 +67,26 @@ public DeleteEmailDialog(
var focusedMessage = state.Message?.FirstOrDefault();
if (focusedMessage != null)
{
return await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions { Prompt = sc.Context.Activity.CreateReply(DeleteEmailResponses.DeleteConfirm) });
var nameListString = DisplayHelper.ToDisplayRecipientsString_Summay(focusedMessage.ToRecipients);
var emailCard = new EmailCardData
{
Subject = string.Format(EmailCommonStrings.SubjectFormat, focusedMessage.Subject),
NameList = string.Format(EmailCommonStrings.ToFormat, nameListString),
EmailContent = string.Format(EmailCommonStrings.ContentFormat, focusedMessage.BodyPreview),
};

var speech = SpeakHelper.ToSpeechEmailSendDetailString(focusedMessage.Subject, nameListString, focusedMessage.BodyPreview);
var stringToken = new StringDictionary
{
{ "EmailDetails", speech },
};
var replyMessage = sc.Context.Activity.CreateAdaptiveCardReply(DeleteEmailResponses.DeleteConfirm, "Dialogs/Shared/Resources/Cards/EmailWithOutButtonCard.json", emailCard, ResponseBuilder, stringToken);

return await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions { Prompt = replyMessage, RetryPrompt = sc.Context.Activity.CreateReply(EmailSharedResponses.ConfirmSendFailed, ResponseBuilder), });
}

return await sc.BeginDialogAsync(Actions.Show, skillOptions);
skillOptions.SubFlowMode = true;
return await sc.BeginDialogAsync(Actions.UpdateSelectMessage, skillOptions);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"replies": [
{
"text": "Are you sure you want to delete?",
"speak": "Are you sure you want to delete?"
"speak": "Are you sure you want to delete? Details of email: {EmailDetails}"
}
],
"inputHint": "expectingInput"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"DeleteConfirm": {
"replies": [
{
"text": "Ok, I'll delete this.",
"speak": "Ok, I'll delete this."
"text": "您确定要删除这封邮件么?",
"speak": "您确定要删除这封邮件么? 邮件内容: {EmailDetails}"
}
],
"inputHint": "expectingInput"
},
"DeleteSuccessfully": {
"replies": [
{
"text": "我已经删除了这个邮件",
"speak": "我已经删除了这个邮件"
"text": "我已经删除了这封邮件",
"speak": "我已经删除了这封邮件"
}
],
"inputHint": "acceptingInput"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public MainDialog(ISkillConfiguration skillConfiguration, ConversationState conv
case Email.Intent.SearchMessages:
case Email.Intent.CheckMessages:
case Email.Intent.ReadAloud:
case Email.Intent.QueryLastText:
{
await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ protected async Task<string> GetPreviewNameListString(WaterfallStepContext sc, s
break;
case Actions.Reply:
case Actions.Forward:
case Actions.Delete:
default:
nameListString = DisplayHelper.ToDisplayRecipientsString_Summay(state.Recipients);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ await this.GetTestFlow()
.AssertReply(this.ShowEmailList())
.AssertReplyOneOf(this.NoFocusMessage())
.Send(BaseTestUtterances.FirstOne)
.AssertReplyOneOf(this.DeleteConfirm())
.AssertReply(this.DeleteConfirm())
.Send(GeneralTestUtterances.No)
.AssertReplyOneOf(this.NotSendingMessage())
.AssertReply(this.ActionEndMessage())
Expand All @@ -49,7 +49,7 @@ await this.GetTestFlow()
.AssertReply(this.ShowEmailList())
.AssertReplyOneOf(this.NoFocusMessage())
.Send(BaseTestUtterances.FirstOne)
.AssertReplyOneOf(this.DeleteConfirm())
.AssertReply(this.DeleteConfirm())
.Send(GeneralTestUtterances.Yes)
.AssertReplyOneOf(this.DeleteSuccess())
.AssertReply(this.ActionEndMessage())
Expand All @@ -71,9 +71,14 @@ private string[] DeleteSuccess()
return this.ParseReplies(DeleteEmailResponses.DeleteSuccessfully.Replies, new StringDictionary());
}

private string[] DeleteConfirm()
private Action<IActivity> DeleteConfirm()
{
return this.ParseReplies(DeleteEmailResponses.DeleteConfirm.Replies, new StringDictionary());
return activity =>
{
var messageActivity = activity.AsMessageActivity();
CollectionAssert.Contains(this.ParseReplies(DeleteEmailResponses.DeleteConfirm.Replies, new StringDictionary()), messageActivity.Text);
Assert.AreEqual(messageActivity.Attachments.Count, 1);
};
}

private Action<IActivity> ActionEndMessage()
Expand Down

0 comments on commit e0aa783

Please sign in to comment.