1
0

fix: api response issue

This commit is contained in:
Ca2didi 2025-05-19 22:19:09 +08:00
parent 4d9e5a9326
commit da9d0a319e
2 changed files with 29 additions and 3 deletions

View 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; }
}

View File

@ -190,13 +190,14 @@ public class RepositoryInnieController(
}
[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 grantIssue = await ValidateRepositoryAsync(userName, repositoryName, user, RepositoryRole.Developer);
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")]