fix: api response issue
This commit is contained in:
parent
4d9e5a9326
commit
da9d0a319e
25
Flawless.Communication/Response/WebhookResponse.cs
Normal file
25
Flawless.Communication/Response/WebhookResponse.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Flawless.Communication.Shared;
|
||||||
|
|
||||||
|
namespace Flawless.Communication.Response;
|
||||||
|
|
||||||
|
public struct WebhookResponse
|
||||||
|
{
|
||||||
|
public WebhookResponse(int id, string targetUrl, WebhookEventType eventType, bool isActive, DateTime createdAt)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
TargetUrl = targetUrl;
|
||||||
|
EventType = eventType;
|
||||||
|
IsActive = isActive;
|
||||||
|
CreatedAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string TargetUrl { get; set; }
|
||||||
|
|
||||||
|
public WebhookEventType EventType { get; set; }
|
||||||
|
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
}
|
||||||
@ -190,13 +190,14 @@ public class RepositoryInnieController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("webhooks")]
|
[HttpGet("webhooks")]
|
||||||
public async Task<ActionResult<IEnumerable<Webhook>>> GetWebhooks(string userName, string repositoryName)
|
public async Task<ActionResult<IEnumerable<WebhookResponse>>> GetWebhooks(string userName, string repositoryName)
|
||||||
{
|
{
|
||||||
var user = (await userManager.GetUserAsync(HttpContext.User))!;
|
var user = (await userManager.GetUserAsync(HttpContext.User))!;
|
||||||
var grantIssue = await ValidateRepositoryAsync(userName, repositoryName, user, RepositoryRole.Developer);
|
var grantIssue = await ValidateRepositoryAsync(userName, repositoryName, user, RepositoryRole.Developer);
|
||||||
if (grantIssue is not Repository rp) return (ActionResult) grantIssue;
|
if (grantIssue is not Repository rp) return (ActionResult) grantIssue;
|
||||||
|
|
||||||
return Ok(await webhookService.GetWebhooksAsync(rp));
|
return Ok((await webhookService.GetWebhooksAsync(rp)).Select(x => new WebhookResponse(
|
||||||
|
x.Id, x.TargetUrl, x.EventType, x.IsActive, x.CreatedAt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("webhooks/{webhookId}/toggle")]
|
[HttpPost("webhooks/{webhookId}/toggle")]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user