2026-02-10 17:49:19 +08:00
|
|
|
using Application;
|
2026-01-28 11:19:23 +08:00
|
|
|
|
|
|
|
|
namespace WebApi.Controllers;
|
2026-01-02 12:25:44 +08:00
|
|
|
|
|
|
|
|
[ApiController]
|
2026-01-02 18:51:28 +08:00
|
|
|
[Route("api/[controller]/[action]")]
|
2026-02-10 17:49:19 +08:00
|
|
|
public class NotificationController(
|
|
|
|
|
INotificationApplication notificationApplication
|
|
|
|
|
) : ControllerBase
|
2026-01-02 12:25:44 +08:00
|
|
|
{
|
2026-01-18 22:04:56 +08:00
|
|
|
[HttpGet]
|
2026-01-02 18:51:28 +08:00
|
|
|
public async Task<BaseResponse<string>> GetVapidPublicKey()
|
2026-01-02 12:25:44 +08:00
|
|
|
{
|
2026-02-10 17:49:19 +08:00
|
|
|
var key = await notificationApplication.GetVapidPublicKeyAsync();
|
|
|
|
|
return key.Ok<string>();
|
2026-01-02 12:25:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-04 16:59:34 +08:00
|
|
|
public async Task<BaseResponse> Subscribe([FromBody] PushSubscription subscription)
|
2026-01-02 12:25:44 +08:00
|
|
|
{
|
2026-02-10 17:49:19 +08:00
|
|
|
await notificationApplication.SubscribeAsync(subscription);
|
|
|
|
|
return BaseResponse.Done();
|
2026-01-02 12:25:44 +08:00
|
|
|
}
|
2026-01-30 10:41:19 +08:00
|
|
|
|
2026-01-02 18:51:28 +08:00
|
|
|
public async Task<BaseResponse> TestNotification([FromQuery] string message)
|
2026-01-02 12:25:44 +08:00
|
|
|
{
|
2026-02-10 17:49:19 +08:00
|
|
|
await notificationApplication.SendNotificationAsync(message);
|
|
|
|
|
return BaseResponse.Done();
|
2026-01-02 12:25:44 +08:00
|
|
|
}
|
|
|
|
|
}
|