30 lines
819 B
C#
30 lines
819 B
C#
using Application;
|
|
|
|
namespace WebApi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]/[action]")]
|
|
public class NotificationController(
|
|
INotificationApplication notificationApplication
|
|
) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<BaseResponse<string>> GetVapidPublicKey()
|
|
{
|
|
var key = await notificationApplication.GetVapidPublicKeyAsync();
|
|
return key.Ok<string>();
|
|
}
|
|
|
|
public async Task<BaseResponse> Subscribe([FromBody] PushSubscription subscription)
|
|
{
|
|
await notificationApplication.SubscribeAsync(subscription);
|
|
return BaseResponse.Done();
|
|
}
|
|
|
|
public async Task<BaseResponse> TestNotification([FromQuery] string message)
|
|
{
|
|
await notificationApplication.SendNotificationAsync(message);
|
|
return BaseResponse.Done();
|
|
}
|
|
}
|