Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Octokit.Webhooks.Events.PullRequestReviewThread
{
using JetBrains.Annotations;

[PublicAPI]
public sealed record PullRequestReviewThreadAction : WebhookEventAction
{
public static readonly PullRequestReviewThreadAction Resolved = new(PullRequestReviewThreadActionValue.Resolved);

public static readonly PullRequestReviewThreadAction Unresolved = new(PullRequestReviewThreadActionValue.Unresolved);

private PullRequestReviewThreadAction(string value)
: base(value)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Octokit.Webhooks.Events.PullRequestReviewThread
{
public static class PullRequestReviewThreadActionValue
{
public const string Resolved = "resolved";

public const string Unresolved = "unresolved";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Octokit.Webhooks.Events.PullRequestReviewThread
{
using System.Text.Json.Serialization;
using JetBrains.Annotations;

[PublicAPI]
[WebhookActionType(PullRequestReviewThreadActionValue.Resolved)]
public sealed record PullRequestReviewThreadResolvedEvent : PullRequestReviewThreadEvent
{
[JsonPropertyName("action")]
public override string Action => PullRequestReviewThreadActionValue.Resolved;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Octokit.Webhooks.Events.PullRequestReviewThread
{
using System.Text.Json.Serialization;
using JetBrains.Annotations;

[PublicAPI]
[WebhookActionType(PullRequestReviewThreadActionValue.Unresolved)]
public sealed record PullRequestReviewThreadUnresolvedEvent : PullRequestReviewThreadEvent
{
[JsonPropertyName("action")]
public override string Action => PullRequestReviewThreadActionValue.Unresolved;
}
}
20 changes: 20 additions & 0 deletions src/Octokit.Webhooks/Events/PullRequestReviewThreadEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Octokit.Webhooks.Events
{
using System.Text.Json.Serialization;
using JetBrains.Annotations;
using Octokit.Webhooks.Converter;
using Octokit.Webhooks.Models;
using Octokit.Webhooks.Models.PullRequestReviewEvent;

[PublicAPI]
[WebhookEventType(WebhookEventType.PullRequestReviewThread)]
[JsonConverter(typeof(WebhookConverter<PullRequestReviewThreadEvent>))]
public abstract record PullRequestReviewThreadEvent : WebhookEvent
{
[JsonPropertyName("review")]
public Review Review { get; init; } = null!;

[JsonPropertyName("pull_request")]
public SimplePullRequest PullRequest { get; init; } = null!;
}
}
4 changes: 2 additions & 2 deletions src/Octokit.Webhooks/Events/StarEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Octokit.Webhooks.Events
public abstract record StarEvent : WebhookEvent
{
[JsonPropertyName("starred_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset StarredAt { get; init; }
[JsonConverter(typeof(NullableDateTimeOffsetConverter))]
public DateTimeOffset? StarredAt { get; init; }
}
}
8 changes: 8 additions & 0 deletions src/Octokit.Webhooks/Models/AppEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum AppEvent
{
[EnumMember(Value = "*")]
All,
[EnumMember(Value = "check_run")]
CheckRun,
[EnumMember(Value = "check_suite")]
Expand Down Expand Up @@ -46,6 +48,8 @@ public enum AppEvent
Member,
[EnumMember(Value = "membership")]
Membership,
[EnumMember(Value = "meta")]
Meta,
[EnumMember(Value = "milestone")]
Milestone,
[EnumMember(Value = "org_block")]
Expand All @@ -68,6 +72,8 @@ public enum AppEvent
PullRequestReview,
[EnumMember(Value = "pull_request_review_comment")]
PullRequestReviewComment,
[EnumMember(Value = "pull_request_review_thread")]
PullRequestReviewThread,
[EnumMember(Value = "push")]
Push,
[EnumMember(Value = "registry_package")]
Expand All @@ -78,6 +84,8 @@ public enum AppEvent
Repository,
[EnumMember(Value = "repository_dispatch")]
RepositoryDispatch,
[EnumMember(Value = "repository_import")]
RepositoryImport,
[EnumMember(Value = "repository_vulnerability_alert")]
RepositoryVulnerabilityAlert,
[EnumMember(Value = "secret_scanning_alert")]
Expand Down
6 changes: 3 additions & 3 deletions src/Octokit.Webhooks/Models/CheckRunEvent/CheckRun.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Octokit.Webhooks.Models.CheckRunEvent
namespace Octokit.Webhooks.Models.CheckRunEvent
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -41,8 +41,8 @@ public sealed record CheckRun
public DateTimeOffset StartedAt { get; init; }

[JsonPropertyName("completed_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset CompletedAt { get; init; }
[JsonConverter(typeof(NullableDateTimeOffsetConverter))]
public DateTimeOffset? CompletedAt { get; init; }

[JsonPropertyName("output")]
public CheckRunOutput Output { get; init; } = null!;
Expand Down
5 changes: 4 additions & 1 deletion src/Octokit.Webhooks/Models/MetaEvent/HookConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
[PublicAPI]
public sealed record HookConfig
{
[JsonPropertyName("secret")]
[JsonPropertyName("content_type")]
public HookConfigContentType ContentType { get; init; }

[JsonPropertyName("url")]
public string Url { get; init; } = null!;

[JsonPropertyName("insecure_ssl")]
public string InsecureSsl { get; init; } = null!;

[JsonPropertyName("secret")]
public string? Secret { get; init; }
}
}
2 changes: 1 addition & 1 deletion src/Octokit.Webhooks/Models/PingEvent/HookConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[PublicAPI]
public sealed record HookConfig
{
[JsonPropertyName("secret")]
[JsonPropertyName("content_type")]
public HookConfigContentType ContentType { get; init; }

[JsonPropertyName("secret")]
Expand Down
6 changes: 3 additions & 3 deletions src/Octokit.Webhooks/Models/ProjectCard.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Octokit.Webhooks.Models
namespace Octokit.Webhooks.Models
{
using System;
using System.Text.Json.Serialization;
Expand Down Expand Up @@ -30,7 +30,7 @@ public sealed record ProjectCard
public string? Note { get; init; }

[JsonPropertyName("archived")]
public long Archived { get; init; }
public bool Archived { get; init; }

[JsonPropertyName("creator")]
public User Creator { get; init; } = null!;
Expand All @@ -47,6 +47,6 @@ public sealed record ProjectCard
public string? ContentUrl { get; init; }

[JsonPropertyName("after_id")]
public long AfterId { get; init; }
public long? AfterId { get; init; }
}
}
16 changes: 16 additions & 0 deletions src/Octokit.Webhooks/Models/PullRequestReviewThreadEvent/Thread.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Octokit.Webhooks.Models.PullRequestReviewThreadEvent
{
using System.Collections.Generic;
using System.Text.Json.Serialization;
using JetBrains.Annotations;

[PublicAPI]
public sealed record Thread
{
[JsonPropertyName("node_id")]
public string NodeId { get; init; } = null!;

[JsonPropertyName("comments")]
public IEnumerable<PullRequestReviewComment> Comments { get; init; } = null!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public sealed record SecurityAdvisoryCvss
public string? VectorString { get; init; }

[JsonPropertyName("score")]
public long Score { get; init; }
public float Score { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace Octokit.Webhooks.Models.WorkflowJobEvent
{
using System;
using System.Text.Json.Serialization;
using JetBrains.Annotations;
using Octokit.Webhooks.Converter;

[PublicAPI]
public sealed record WorkflowJobStep
Expand All @@ -13,7 +15,7 @@ public sealed record WorkflowJobStep
public WorkflowJobStepStatus Status { get; init; }

[JsonPropertyName("conclusion")]
public WorkflowJobStepConclusion Conclusion { get; init; }
public WorkflowJobStepConclusion? Conclusion { get; init; }

[JsonPropertyName("number")]
public long Number { get; init; }
Expand All @@ -22,6 +24,7 @@ public sealed record WorkflowJobStep
public string StartedAt { get; init; } = null!;

[JsonPropertyName("completed_at")]
public string? CompletedAt { get; init; }
[JsonConverter(typeof(NullableDateTimeOffsetConverter))]
public DateTimeOffset? CompletedAt { get; init; }
}
}
1 change: 1 addition & 0 deletions src/Octokit.Webhooks/WebHookEventType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static class WebhookEventType
public const string PullRequest = "pull_request";
public const string PullRequestReview = "pull_request_review";
public const string PullRequestReviewComment = "pull_request_review_comment";
public const string PullRequestReviewThread = "pull_request_review_thread";
public const string Push = "push";
public const string RegistryPackage = "registry_package";
public const string Release = "release";
Expand Down
20 changes: 20 additions & 0 deletions src/Octokit.Webhooks/WebhookEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using Octokit.Webhooks.Events.PullRequest;
using Octokit.Webhooks.Events.PullRequestReview;
using Octokit.Webhooks.Events.PullRequestReviewComment;
using Octokit.Webhooks.Events.PullRequestReviewThread;
using Octokit.Webhooks.Events.Release;
using Octokit.Webhooks.Events.Repository;
using Octokit.Webhooks.Events.RepositoryDispatch;
Expand Down Expand Up @@ -127,6 +128,8 @@ public virtual Task ProcessWebhookAsync(WebhookHeaders headers, WebhookEvent web
pullRequestReviewEvent),
PullRequestReviewCommentEvent pullRequestReviewCommentEvent => this
.ProcessPullRequestReviewCommentWebhookAsync(headers, pullRequestReviewCommentEvent),
PullRequestReviewThreadEvent pullRequestReviewThreadEvent => this
.ProcessPullRequestReviewThreadWebhookAsync(headers, pullRequestReviewThreadEvent),
PushEvent pushEvent => this.ProcessPushWebhookAsync(headers, pushEvent),
ReleaseEvent releaseEvent => this.ProcessReleaseWebhookAsync(headers, releaseEvent),
RepositoryEvent repositoryEvent => this.ProcessRepositoryWebhookAsync(headers, repositoryEvent),
Expand Down Expand Up @@ -200,6 +203,8 @@ public virtual WebhookEvent DeserializeWebhookEvent(WebhookHeaders headers, stri
WebhookEventType.PullRequestReview => JsonSerializer.Deserialize<PullRequestReviewEvent>(body)!,
WebhookEventType.PullRequestReviewComment =>
JsonSerializer.Deserialize<PullRequestReviewCommentEvent>(body)!,
WebhookEventType.PullRequestReviewThread =>
JsonSerializer.Deserialize<PullRequestReviewThreadEvent>(body)!,
WebhookEventType.Push => JsonSerializer.Deserialize<PushEvent>(body)!,
WebhookEventType.Release => JsonSerializer.Deserialize<ReleaseEvent>(body)!,
WebhookEventType.Repository => JsonSerializer.Deserialize<RepositoryEvent>(body)!,
Expand Down Expand Up @@ -831,6 +836,21 @@ private Task ProcessPullRequestReviewCommentWebhookAsync(WebhookHeaders headers,
[PublicAPI]
protected virtual Task ProcessPullRequestReviewCommentWebhookAsync(WebhookHeaders headers, PullRequestReviewCommentEvent pullRequestReviewCommentEvent, PullRequestReviewCommentAction action) => Task.CompletedTask;

private Task ProcessPullRequestReviewThreadWebhookAsync(WebhookHeaders headers, PullRequestReviewThreadEvent pullRequestReviewThreadEvent)
{
return pullRequestReviewThreadEvent.Action switch
{
PullRequestReviewThreadActionValue.Resolved => this.ProcessPullRequestReviewThreadWebhookAsync(headers,
pullRequestReviewThreadEvent, PullRequestReviewThreadAction.Resolved),
PullRequestReviewThreadActionValue.Unresolved => this.ProcessPullRequestReviewThreadWebhookAsync(headers,
pullRequestReviewThreadEvent, PullRequestReviewThreadAction.Unresolved),
_ => Task.CompletedTask
};
}

[PublicAPI]
protected virtual Task ProcessPullRequestReviewThreadWebhookAsync(WebhookHeaders headers, PullRequestReviewThreadEvent pullRequestReviewThreadEvent, PullRequestReviewThreadAction action) => Task.CompletedTask;

[PublicAPI]
protected virtual Task ProcessPushWebhookAsync(WebhookHeaders headers, PushEvent pushEvent) => Task.CompletedTask;

Expand Down
Loading