mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 22:38:30 +01:00
support delete per library
This commit is contained in:
@@ -477,14 +477,36 @@ namespace MediaBrowser.Controller.Entities
|
||||
locationType != LocationType.Virtual;
|
||||
}
|
||||
|
||||
public virtual bool IsAuthorizedToDelete(User user)
|
||||
public virtual bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return user.Policy.EnableContentDeletion;
|
||||
if (user.Policy.EnableContentDeletion)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var allowed = user.Policy.EnableContentDeletionFromFolders;
|
||||
var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
|
||||
|
||||
foreach (var folder in collectionFolders)
|
||||
{
|
||||
if (allowed.Contains(folder.Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CanDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return CanDelete() && IsAuthorizedToDelete(user, allCollectionFolders);
|
||||
}
|
||||
|
||||
public bool CanDelete(User user)
|
||||
{
|
||||
return CanDelete() && IsAuthorizedToDelete(user);
|
||||
var allCollectionFolders = LibraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
|
||||
return CanDelete(user, allCollectionFolders);
|
||||
}
|
||||
|
||||
public virtual bool CanDownload()
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsAuthorizedToDelete(User user)
|
||||
public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace MediaBrowser.Controller.LiveTv
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool IsAuthorizedToDelete(User user)
|
||||
public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return user.Policy.EnableLiveTvManagement;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace MediaBrowser.Controller.LiveTv
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool IsAuthorizedToDelete(User user)
|
||||
public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return user.Policy.EnableLiveTvManagement;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
||||
namespace MediaBrowser.Controller.Notifications
|
||||
{
|
||||
@@ -15,6 +16,8 @@ namespace MediaBrowser.Controller.Notifications
|
||||
/// <returns>Task.</returns>
|
||||
Task SendNotification(NotificationRequest request, CancellationToken cancellationToken);
|
||||
|
||||
Task SendNotification(NotificationRequest request, BaseItem relatedItem, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace MediaBrowser.Controller.Playlists
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override bool IsAuthorizedToDelete(User user)
|
||||
public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user