|
@@ -1,5 +1,11 @@
|
|
|
|
+#pragma warning disable CS1591
|
|
|
|
+#pragma warning disable SA1402
|
|
|
|
+#pragma warning disable SA1600
|
|
|
|
+#pragma warning disable SA1649
|
|
|
|
+
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
@@ -16,7 +22,7 @@ namespace Emby.Notifications.Api
|
|
public class GetNotifications : IReturn<NotificationResult>
|
|
public class GetNotifications : IReturn<NotificationResult>
|
|
{
|
|
{
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
- public string UserId { get; set; }
|
|
|
|
|
|
+ public string UserId { get; set; } = string.Empty;
|
|
|
|
|
|
[ApiMember(Name = "IsRead", Description = "An optional filter by IsRead", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
|
[ApiMember(Name = "IsRead", Description = "An optional filter by IsRead", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
|
public bool? IsRead { get; set; }
|
|
public bool? IsRead { get; set; }
|
|
@@ -30,32 +36,34 @@ namespace Emby.Notifications.Api
|
|
|
|
|
|
public class Notification
|
|
public class Notification
|
|
{
|
|
{
|
|
- public string Id { get; set; }
|
|
|
|
|
|
+ public string Id { get; set; } = string.Empty;
|
|
|
|
|
|
- public string UserId { get; set; }
|
|
|
|
|
|
+ public string UserId { get; set; } = string.Empty;
|
|
|
|
|
|
public DateTime Date { get; set; }
|
|
public DateTime Date { get; set; }
|
|
|
|
|
|
public bool IsRead { get; set; }
|
|
public bool IsRead { get; set; }
|
|
|
|
|
|
- public string Name { get; set; }
|
|
|
|
|
|
+ public string Name { get; set; } = string.Empty;
|
|
|
|
|
|
- public string Description { get; set; }
|
|
|
|
|
|
+ public string Description { get; set; } = string.Empty;
|
|
|
|
|
|
- public string Url { get; set; }
|
|
|
|
|
|
+ public string Url { get; set; } = string.Empty;
|
|
|
|
|
|
public NotificationLevel Level { get; set; }
|
|
public NotificationLevel Level { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
public class NotificationResult
|
|
public class NotificationResult
|
|
{
|
|
{
|
|
- public Notification[] Notifications { get; set; }
|
|
|
|
|
|
+ public IReadOnlyList<Notification> Notifications { get; set; } = Array.Empty<Notification>();
|
|
|
|
+
|
|
public int TotalRecordCount { get; set; }
|
|
public int TotalRecordCount { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
public class NotificationsSummary
|
|
public class NotificationsSummary
|
|
{
|
|
{
|
|
public int UnreadCount { get; set; }
|
|
public int UnreadCount { get; set; }
|
|
|
|
+
|
|
public NotificationLevel MaxUnreadNotificationLevel { get; set; }
|
|
public NotificationLevel MaxUnreadNotificationLevel { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
@@ -63,7 +71,7 @@ namespace Emby.Notifications.Api
|
|
public class GetNotificationsSummary : IReturn<NotificationsSummary>
|
|
public class GetNotificationsSummary : IReturn<NotificationsSummary>
|
|
{
|
|
{
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
- public string UserId { get; set; }
|
|
|
|
|
|
+ public string UserId { get; set; } = string.Empty;
|
|
}
|
|
}
|
|
|
|
|
|
[Route("/Notifications/Types", "GET", Summary = "Gets notification types")]
|
|
[Route("/Notifications/Types", "GET", Summary = "Gets notification types")]
|
|
@@ -80,16 +88,16 @@ namespace Emby.Notifications.Api
|
|
public class AddAdminNotification : IReturnVoid
|
|
public class AddAdminNotification : IReturnVoid
|
|
{
|
|
{
|
|
[ApiMember(Name = "Name", Description = "The notification's name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
[ApiMember(Name = "Name", Description = "The notification's name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
- public string Name { get; set; }
|
|
|
|
|
|
+ public string Name { get; set; } = string.Empty;
|
|
|
|
|
|
[ApiMember(Name = "Description", Description = "The notification's description", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
[ApiMember(Name = "Description", Description = "The notification's description", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
- public string Description { get; set; }
|
|
|
|
|
|
+ public string Description { get; set; } = string.Empty;
|
|
|
|
|
|
[ApiMember(Name = "ImageUrl", Description = "The notification's image url", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
[ApiMember(Name = "ImageUrl", Description = "The notification's image url", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
- public string ImageUrl { get; set; }
|
|
|
|
|
|
+ public string? ImageUrl { get; set; }
|
|
|
|
|
|
[ApiMember(Name = "Url", Description = "The notification's info url", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
[ApiMember(Name = "Url", Description = "The notification's info url", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
- public string Url { get; set; }
|
|
|
|
|
|
+ public string? Url { get; set; }
|
|
|
|
|
|
[ApiMember(Name = "Level", Description = "The notification level", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
[ApiMember(Name = "Level", Description = "The notification level", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
public NotificationLevel Level { get; set; }
|
|
public NotificationLevel Level { get; set; }
|
|
@@ -99,20 +107,20 @@ namespace Emby.Notifications.Api
|
|
public class MarkRead : IReturnVoid
|
|
public class MarkRead : IReturnVoid
|
|
{
|
|
{
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
|
- public string UserId { get; set; }
|
|
|
|
|
|
+ public string UserId { get; set; } = string.Empty;
|
|
|
|
|
|
[ApiMember(Name = "Ids", Description = "A list of notification ids, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST", AllowMultiple = true)]
|
|
[ApiMember(Name = "Ids", Description = "A list of notification ids, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST", AllowMultiple = true)]
|
|
- public string Ids { get; set; }
|
|
|
|
|
|
+ public string Ids { get; set; } = string.Empty;
|
|
}
|
|
}
|
|
|
|
|
|
[Route("/Notifications/{UserId}/Unread", "POST", Summary = "Marks notifications as unread")]
|
|
[Route("/Notifications/{UserId}/Unread", "POST", Summary = "Marks notifications as unread")]
|
|
public class MarkUnread : IReturnVoid
|
|
public class MarkUnread : IReturnVoid
|
|
{
|
|
{
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
|
- public string UserId { get; set; }
|
|
|
|
|
|
+ public string UserId { get; set; } = string.Empty;
|
|
|
|
|
|
[ApiMember(Name = "Ids", Description = "A list of notification ids, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST", AllowMultiple = true)]
|
|
[ApiMember(Name = "Ids", Description = "A list of notification ids, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST", AllowMultiple = true)]
|
|
- public string Ids { get; set; }
|
|
|
|
|
|
+ public string Ids { get; set; } = string.Empty;
|
|
}
|
|
}
|
|
|
|
|
|
[Authenticated]
|
|
[Authenticated]
|
|
@@ -127,32 +135,29 @@ namespace Emby.Notifications.Api
|
|
_userManager = userManager;
|
|
_userManager = userManager;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")]
|
|
public object Get(GetNotificationTypes request)
|
|
public object Get(GetNotificationTypes request)
|
|
{
|
|
{
|
|
return _notificationManager.GetNotificationTypes();
|
|
return _notificationManager.GetNotificationTypes();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")]
|
|
public object Get(GetNotificationServices request)
|
|
public object Get(GetNotificationServices request)
|
|
{
|
|
{
|
|
return _notificationManager.GetNotificationServices().ToList();
|
|
return _notificationManager.GetNotificationServices().ToList();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")]
|
|
public object Get(GetNotificationsSummary request)
|
|
public object Get(GetNotificationsSummary request)
|
|
{
|
|
{
|
|
return new NotificationsSummary
|
|
return new NotificationsSummary
|
|
{
|
|
{
|
|
-
|
|
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
public Task Post(AddAdminNotification request)
|
|
public Task Post(AddAdminNotification request)
|
|
{
|
|
{
|
|
// This endpoint really just exists as post of a real with sickbeard
|
|
// This endpoint really just exists as post of a real with sickbeard
|
|
- return AddNotification(request);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private Task AddNotification(AddAdminNotification request)
|
|
|
|
- {
|
|
|
|
var notification = new NotificationRequest
|
|
var notification = new NotificationRequest
|
|
{
|
|
{
|
|
Date = DateTime.UtcNow,
|
|
Date = DateTime.UtcNow,
|
|
@@ -166,14 +171,17 @@ namespace Emby.Notifications.Api
|
|
return _notificationManager.SendNotification(notification, CancellationToken.None);
|
|
return _notificationManager.SendNotification(notification, CancellationToken.None);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")]
|
|
public void Post(MarkRead request)
|
|
public void Post(MarkRead request)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")]
|
|
public void Post(MarkUnread request)
|
|
public void Post(MarkUnread request)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")]
|
|
public object Get(GetNotifications request)
|
|
public object Get(GetNotifications request)
|
|
{
|
|
{
|
|
return new NotificationResult();
|
|
return new NotificationResult();
|