Esempio n. 1
0
        private async Task TransitIssueAsync(IDurableOrchestrationContext context,
                                             PullRequestStateContext pullRequestStateContext,
                                             CommandHookContext commandHookContext)
        {
            // GetIssue that match Scan Provider
            CreatedReviewComment parentReviewComment =
                GetParentReviewCommentAsync(pullRequestStateContext, commandHookContext);

            var issue = await GetIssueAsync(context, pullRequestStateContext, parentReviewComment);

            // Update the Issue state

            if (issue.Status == "OPEN" || issue.Status == "REOPEN")
            {
                await context.CallActivityAsync(nameof(CommandOrchestrator) + "_" + parentReviewComment.ScanProvider +
                                                "_TransitIssue", new TransitIssueContext()
                {
                    CreatedReviewComment = parentReviewComment,
                    Transition           = CommandRouter.GetTransition(commandHookContext.Command),
                    Issue = issue
                });

                // Create Comment that match Repository Provider

                await context.CallActivityAsync(
                    nameof(CommandOrchestrator) + "_" + BotConfiguration.RepositoryProvider +
                    "_CreateIssueTransitionReplyComment", new CreateIssueTransitionReplyCommentContext()
                {
                    PullRequestId = commandHookContext.PullRequestId,
                    InReplyTo     = commandHookContext.ReplyToId,
                    Command       = commandHookContext.Command,
                    Issue         = issue
                });
            }
            else // Issue is already resolved or confirmed
            {
                await context.CallActivityAsync(nameof(CommandOrchestrator) + "_" + BotConfiguration.RepositoryProvider +
                                                "_CreateSimpleReplyComment", new CreateSimpleReplyCommentContext()
                {
                    Body          = "The issue is already resolved or confirmed.",
                    InReplyTo     = commandHookContext.ReplyToId,
                    PullRequestId = commandHookContext.PullRequestId
                });
            }
        }