2026-02-10 17:49:19 +08:00
|
|
|
using Service.Message;
|
|
|
|
|
|
|
|
|
|
namespace Application;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通知应用服务接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface INotificationApplication
|
|
|
|
|
{
|
|
|
|
|
Task<string> GetVapidPublicKeyAsync();
|
|
|
|
|
Task SubscribeAsync(PushSubscription subscription);
|
|
|
|
|
Task SendNotificationAsync(string message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通知应用服务实现
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class NotificationApplication(
|
2026-02-11 13:00:01 +08:00
|
|
|
INotificationService notificationService
|
2026-02-10 17:49:19 +08:00
|
|
|
) : INotificationApplication
|
|
|
|
|
{
|
|
|
|
|
public async Task<string> GetVapidPublicKeyAsync()
|
|
|
|
|
{
|
|
|
|
|
return await notificationService.GetVapidPublicKeyAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task SubscribeAsync(PushSubscription subscription)
|
|
|
|
|
{
|
|
|
|
|
await notificationService.SubscribeAsync(subscription);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task SendNotificationAsync(string message)
|
|
|
|
|
{
|
|
|
|
|
await notificationService.SendNotificationAsync(message);
|
|
|
|
|
}
|
|
|
|
|
}
|