Add notification inbox and restrict email logging
This commit is contained in:
1 parent
33b6864d3b
commit
9ca23a2c15
5 files changed
+114
-3
No files matched your search
@@ -0,0 +1,39 @@
|
||||
using Helpdesk.Application.Common;
|
||||
using Helpdesk.Application.Notifications;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Helpdesk.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/notifications")]
|
||||
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
|
||||
[ProducesResponseType<ProblemDetails>(StatusCodes.Status401Unauthorized)]
|
||||
public sealed class NotificationsController(NotificationService notifications) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public Task<PagedResult<NotificationDto>> List(
|
||||
[FromQuery] bool unreadOnly = false, [FromQuery] int page = 1, [FromQuery] int pageSize = 20,
|
||||
CancellationToken ct = default) => notifications.ListAsync(unreadOnly, page, pageSize, ct);
|
||||
|
||||
[HttpGet("unread-count")]
|
||||
public Task<UnreadCountDto> CountUnread(CancellationToken ct) => notifications.CountUnreadAsync(ct);
|
||||
|
||||
[HttpPost("{id:int}/read")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType<ProblemDetails>(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> MarkRead(int id, CancellationToken ct)
|
||||
{
|
||||
await notifications.MarkReadAsync(id, ct);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpPost("read-all")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> MarkAllRead(CancellationToken ct)
|
||||
{
|
||||
await notifications.MarkAllReadAsync(ct);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user