fix
This commit is contained in:
@@ -1,27 +1,46 @@
|
||||
namespace WebApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class NotificationController(INotificationService notificationService) : ControllerBase
|
||||
{
|
||||
[HttpGet("vapid-public-key")]
|
||||
public async Task<IActionResult> GetVapidPublicKey()
|
||||
[HttpGet()]
|
||||
public async Task<BaseResponse<string>> GetVapidPublicKey()
|
||||
{
|
||||
var key = await notificationService.GetVapidPublicKeyAsync();
|
||||
return Ok(new { publicKey = key });
|
||||
try
|
||||
{
|
||||
var key = await notificationService.GetVapidPublicKeyAsync();
|
||||
return BaseResponse<string>.Done(key);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BaseResponse<string>.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("subscribe")]
|
||||
public async Task<IActionResult> Subscribe([FromBody] PushSubscriptionEntity subscription)
|
||||
public async Task<BaseResponse> Subscribe([FromBody] PushSubscriptionEntity subscription)
|
||||
{
|
||||
await notificationService.SubscribeAsync(subscription);
|
||||
return Ok();
|
||||
try
|
||||
{
|
||||
await notificationService.SubscribeAsync(subscription);
|
||||
return BaseResponse.Done();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BaseResponse.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("test")]
|
||||
public async Task<IActionResult> TestNotification([FromQuery] string message)
|
||||
public async Task<BaseResponse> TestNotification([FromQuery] string message)
|
||||
{
|
||||
await notificationService.SendNotificationAsync(message);
|
||||
return Ok();
|
||||
try
|
||||
{
|
||||
await notificationService.SendNotificationAsync(message);
|
||||
return BaseResponse.Done();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BaseResponse.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user