private static MattermostMessage GetMessageCommitComment(CommitCommentEvent payload) { var retVal = BaseMessageForRepo(payload.repository.full_name); MattermostAttachment att = null; var repoMd = $"[{payload.repository.full_name}]({payload.repository.html_url})"; var commitMd = $"[`{payload.comment.commit_id.Substring(0, 7)}`]({payload.comment.html_url})"; var userMd = $"[{payload.sender.login}]({payload.sender.html_url})"; if (payload.action == "created") { retVal.Text = $"{userMd} commented on {commitMd} in {repoMd}"; att = new MattermostAttachment { Text = payload.comment.body }; } else { throw new NotImplementedException($"Unhandled Event action: {payload.action}"); } retVal.Attachments = new List <MattermostAttachment> { att }; return(retVal); }
private object ConvertPayload() { switch (Event) { case PingEvent.EventString: return(PingEvent.FromJson(PayloadText)); case CommitCommentEvent.EventString: return(CommitCommentEvent.FromJson(PayloadText)); case CreateEvent.EventString: return(CreateEvent.FromJson(PayloadText)); case DeleteEvent.EventString: return(DeleteEvent.FromJson(PayloadText)); case DeploymentEvent.EventString: return(DeploymentEvent.FromJson(PayloadText)); case DeploymentStatusEvent.EventString: return(DeploymentStatusEvent.FromJson(PayloadText)); case ForkEvent.EventString: return(ForkEvent.FromJson(PayloadText)); case GollumEvent.EventString: return(GollumEvent.FromJson(PayloadText)); case InstallationEvent.EventString: return(InstallationEvent.FromJson(PayloadText)); case InstallationRepositoriesEvent.EventString: return(InstallationRepositoriesEvent.FromJson(PayloadText)); case IssueCommentEvent.EventString: return(IssueCommentEvent.FromJson(PayloadText)); case IssuesEvent.EventString: return(IssuesEvent.FromJson(PayloadText)); case LabelEvent.EventString: return(LabelEvent.FromJson(PayloadText)); case MemberEvent.EventString: return(MemberEvent.FromJson(PayloadText)); case MembershipEvent.EventString: return(MembershipEvent.FromJson(PayloadText)); case MilestoneEvent.EventString: return(MilestoneEvent.FromJson(PayloadText)); case OrganizationEvent.EventString: return(OrganizationEvent.FromJson(PayloadText)); case OrgBlockEvent.EventString: return(OrgBlockEvent.FromJson(PayloadText)); case PageBuildEvent.EventString: return(PageBuildEvent.FromJson(PayloadText)); case ProjectCardEvent.EventString: return(ProjectCardEvent.FromJson(PayloadText)); case ProjectColumnEvent.EventString: return(ProjectColumnEvent.FromJson(PayloadText)); case ProjectEvent.EventString: return(ProjectEvent.FromJson(PayloadText)); case PublicEvent.EventString: return(PublicEvent.FromJson(PayloadText)); case PullRequestEvent.EventString: return(PullRequestEvent.FromJson(PayloadText)); case PullRequestReviewEvent.EventString: return(PullRequestReviewEvent.FromJson(PayloadText)); case PullRequestReviewCommentEvent.EventString: return(PullRequestReviewCommentEvent.FromJson(PayloadText)); case PushEvent.EventString: return(PushEvent.FromJson(PayloadText)); case ReleaseEvent.EventString: return(ReleaseEvent.FromJson(PayloadText)); case RepositoryEvent.EventString: return(RepositoryEvent.FromJson(PayloadText)); case StatusEvent.EventString: return(StatusEvent.FromJson(PayloadText)); case WatchEvent.EventString: return(WatchEvent.FromJson(PayloadText)); default: throw new NotImplementedException( $"Event Type: `{Event}` is not implemented. Want it added? Open an issue at https://github.com/promofaux/GithubWebhooks"); } }