mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-01 20:23:13 +00:00
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
|
|
using Microsoft.AspNetCore.Authorization;
|
||
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using SeaHaven.Services.Exceptions;
|
||
|
|
using SeaHaven.Services.Interfaces;
|
||
|
|
|
||
|
|
namespace Api.SeaHavenIndustries.Controllers
|
||
|
|
{
|
||
|
|
[Authorize]
|
||
|
|
[ApiController]
|
||
|
|
[Route("api/notifications")]
|
||
|
|
public class NotificationsController : ControllerBase
|
||
|
|
{
|
||
|
|
private readonly INotificationFeedService _feedService;
|
||
|
|
|
||
|
|
public NotificationsController(INotificationFeedService feedService)
|
||
|
|
{
|
||
|
|
_feedService = feedService;
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpGet]
|
||
|
|
public async Task<IActionResult> GetFeed(CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
return Ok(await _feedService.GetFeedAsync(User, cancellationToken));
|
||
|
|
}
|
||
|
|
catch (WorkOrderBoardValidationException ex) when (ex.Code == "Forbidden")
|
||
|
|
{
|
||
|
|
return StatusCode(StatusCodes.Status403Forbidden, new
|
||
|
|
{
|
||
|
|
code = ex.Code,
|
||
|
|
message = ex.Message
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|