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