public async Task IssueComment(DateTimeOffset eventDate, IssueCommentPayload payload)
        {
            var updater = new DataUpdater(_contextFactory, _mapper);

            // Ensure the issue that owns this comment exists locally before we add the comment.
            await updater.UpdateRepositories(eventDate, new[] { payload.Repository });

            await updater.UpdateIssues(payload.Repository.Id, eventDate, new[] { payload.Issue });

            switch (payload.Action)
            {
            case "created":
                await updater.UpdateIssueComments(payload.Repository.Id, eventDate, new[] { payload.Comment });

                break;

            case "edited":
                // GitHub doesn't send the new comment body. We have to look it up ourselves.
                var repoActor = _grainFactory.GetGrain <IRepositoryActor>(payload.Repository.Id);
                await repoActor.RefreshIssueComment(payload.Comment.Id);

                break;

            case "deleted":
                await updater.DeleteIssueComment(payload.Comment.Id, null);

                break;

            default:
                throw new NotImplementedException($"Action '{payload.Action}' is not valid for event {nameof(IssueComment)}.");
            }

            await updater.Changes.Submit(_queueClient);
        }
Exemple #2
0
 /// <inheritdoc />
 public void ProcessPayload(IssueCommentPayload payload)
 {
     if (payload.Action != "created" || payload.Comment.Body == null || !payload.Comment.Body.Split(' ').Any(x => x == String.Format(CultureInfo.InvariantCulture, "@{0}", gitHubConfiguration.TagUser)))
     {
         return;
     }
     backgroundJobClient.Enqueue(() => ScanPullRequest(payload.Repository.Id, payload.Issue.Number, JobCancellationToken.Null));
 }