mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-02 22:08:27 +01:00
rework notifications infrastructure
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Dto
|
||||
@@ -33,14 +32,6 @@ namespace MediaBrowser.Controller.Dto
|
||||
/// <returns>UserItemDataDto.</returns>
|
||||
UserItemDataDto GetUserItemDataDto(UserItemData data);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item by dto id.
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
BaseItem GetItemByDtoId(string id, Guid? userId = null);
|
||||
|
||||
/// <summary>
|
||||
/// Attaches the primary image aspect ratio.
|
||||
/// </summary>
|
||||
|
||||
@@ -342,5 +342,10 @@ namespace MediaBrowser.Controller.Library
|
||||
DeleteFileLocation = true
|
||||
});
|
||||
}
|
||||
|
||||
public static BaseItem GetItemById(this ILibraryManager manager, string id)
|
||||
{
|
||||
return manager.GetItemById(new Guid(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,8 +167,10 @@
|
||||
<Compile Include="Net\IHttpServer.cs" />
|
||||
<Compile Include="Net\IRestfulService.cs" />
|
||||
<Compile Include="News\INewsService.cs" />
|
||||
<Compile Include="Notifications\INotificationManager.cs" />
|
||||
<Compile Include="Notifications\INotificationsRepository.cs" />
|
||||
<Compile Include="Notifications\NotificationUpdateEventArgs.cs" />
|
||||
<Compile Include="Notifications\UserNotification.cs" />
|
||||
<Compile Include="Persistence\IFileOrganizationRepository.cs" />
|
||||
<Compile Include="Persistence\MediaStreamQuery.cs" />
|
||||
<Compile Include="Providers\DirectoryService.cs" />
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Notifications
|
||||
{
|
||||
public interface INotificationManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Sends the notification.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendNotification(NotificationRequest request, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
/// <param name="services">The services.</param>
|
||||
void AddParts(IEnumerable<INotificationService> services);
|
||||
}
|
||||
|
||||
public interface INotificationService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sends the notification.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendNotification(UserNotification request, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is enabled for user] [the specified user identifier].
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns><c>true</c> if [is enabled for user] [the specified user identifier]; otherwise, <c>false</c>.</returns>
|
||||
bool IsEnabledForUser(User user);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
using System.Threading;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Notifications
|
||||
@@ -44,7 +43,7 @@ namespace MediaBrowser.Controller.Notifications
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <returns>Notification.</returns>
|
||||
Notification GetNotification(Guid id, Guid userId);
|
||||
Notification GetNotification(string id, string userId);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the notification.
|
||||
@@ -54,14 +53,6 @@ namespace MediaBrowser.Controller.Notifications
|
||||
/// <returns>Task.</returns>
|
||||
Task AddNotification(Notification notification, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the notification.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task UpdateNotification(Notification notification, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Marks the read.
|
||||
/// </summary>
|
||||
@@ -70,13 +61,13 @@ namespace MediaBrowser.Controller.Notifications
|
||||
/// <param name="isRead">if set to <c>true</c> [is read].</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task MarkRead(IEnumerable<Guid> notificationIdList, Guid userId, bool isRead, CancellationToken cancellationToken);
|
||||
Task MarkRead(IEnumerable<string> notificationIdList, string userId, bool isRead, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the notifications summary.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <returns>NotificationsSummary.</returns>
|
||||
NotificationsSummary GetNotificationsSummary(Guid userId);
|
||||
NotificationsSummary GetNotificationsSummary(string userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace MediaBrowser.Controller.Notifications
|
||||
|
||||
public class NotificationReadEventArgs : EventArgs
|
||||
{
|
||||
public Guid[] IdList { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string[] IdList { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public bool IsRead { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
21
MediaBrowser.Controller/Notifications/UserNotification.cs
Normal file
21
MediaBrowser.Controller/Notifications/UserNotification.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Notifications
|
||||
{
|
||||
public class UserNotification
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
public NotificationLevel Level { get; set; }
|
||||
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public User User { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user