All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 22s
Docker Build & Deploy / Deploy to Production (push) Successful in 7s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
- 创建 LogCleanupJob 替代 LogCleanupService (BackgroundService) - 在 Expand.cs 中注册 LogCleanupJob (每天凌晨2点执行, 保留30天日志) - 从 Program.cs 移除 LogCleanupService 的 HostedService 注册 - 删除 Service/LogCleanupService.cs - 删除 Service/PeriodicBillBackgroundService.cs (已无用的重复服务) 所有后台任务现在统一通过 Quartz.NET 管理, 支持运行时控制
49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using Service.Message;
|
|
|
|
namespace WebApi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]/[action]")]
|
|
public class NotificationController(INotificationService notificationService) : 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>();
|
|
}
|
|
}
|
|
|
|
public async Task<BaseResponse> Subscribe([FromBody] PushSubscription subscription)
|
|
{
|
|
try
|
|
{
|
|
await notificationService.SubscribeAsync(subscription);
|
|
return BaseResponse.Done();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message.Fail();
|
|
}
|
|
}
|
|
|
|
public async Task<BaseResponse> TestNotification([FromQuery] string message)
|
|
{
|
|
try
|
|
{
|
|
await notificationService.SendNotificationAsync(message);
|
|
return BaseResponse.Done();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message.Fail();
|
|
}
|
|
}
|
|
}
|