using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.ShareLinks.Services;
using MediaBrowser.Model.Tasks;
namespace Jellyfin.Plugin.ShareLinks.Tasks;
///
/// Scheduled cleanup shell for later link-expiry and guest-account teardown work.
///
public sealed class CleanupShareLinksScheduledTask : IScheduledTask, IConfigurableScheduledTask
{
private readonly IShareLinkCleanupService _cleanupService;
/// Initializes a new instance of the class.
public CleanupShareLinksScheduledTask(IShareLinkCleanupService cleanupService)
{
_cleanupService = cleanupService;
}
///
public string Name => "Clean up ShareLinks";
///
public string Key => "ShareLinksCleanup";
///
public string Description => "Removes expired share links and performs future guest-account cleanup.";
///
public string Category => "ShareLinks";
///
public bool IsHidden => false;
///
public bool IsEnabled => true;
///
public bool IsLogged => true;
///
public async Task ExecuteAsync(IProgress progress, CancellationToken cancellationToken)
{
_ = progress;
await _cleanupService.CleanupAsync(cancellationToken).ConfigureAwait(false);
}
///
public IEnumerable GetDefaultTriggers()
{
yield return new TaskTriggerInfo
{
Type = TaskTriggerInfoType.DailyTrigger,
TimeOfDayTicks = TimeSpan.FromHours(4).Ticks,
};
}
}