From 0ed2c014a84f8d25659ac928ea1037e00f3f457c Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Fri, 21 Feb 2020 21:24:51 +0000 Subject: [PATCH] Fixed duplicate key --- .../NotificationMessageCurlys.cs | 1 - src/Ombi/Controllers/V2/MobileController.cs | 23 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs index def74ea79..8140a4d3f 100644 --- a/src/Ombi.Notifications/NotificationMessageCurlys.cs +++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs @@ -282,7 +282,6 @@ namespace Ombi.Notifications {nameof(UserPreference),UserPreference}, {nameof(DenyReason),DenyReason}, {nameof(AvailableDate),AvailableDate}, - {nameof(RequestId),RequestId}, }; } } \ No newline at end of file diff --git a/src/Ombi/Controllers/V2/MobileController.cs b/src/Ombi/Controllers/V2/MobileController.cs index be96faa98..f6185e18e 100644 --- a/src/Ombi/Controllers/V2/MobileController.cs +++ b/src/Ombi/Controllers/V2/MobileController.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; namespace Ombi.Controllers.V2 { - [ApiV2] + [ApiV2] [Authorize] [Produces("application/json")] [ApiController] @@ -56,5 +56,26 @@ namespace Ombi.Controllers.V2 } return BadRequest(); } + + [HttpDelete("Notification")] + [ApiExplorerSettings(IgnoreApi = true)] + [ProducesResponseType(400)] + [ProducesResponseType(200)] + public async Task RemoveNotifications() + { + + var user = await _userManager.Users.FirstOrDefaultAsync(x => x.UserName.Equals(User.Identity.Name, StringComparison.InvariantCultureIgnoreCase)); + // Check if we already have this notification id + var currentDevices = await _mobileDevices.GetAll().Where(x => x.UserId == user.Id).ToListAsync(); + + if (currentDevices == null || !currentDevices.Any()) + { + return Ok(); + } + + await _mobileDevices.DeleteRange(currentDevices); + + return Ok(); + } } }