mirror of
https://github.com/jellyfin/jellyfin-plugin-trakt.git
synced 2024-11-26 23:30:25 +00:00
Cleanup plugin configuration
This commit is contained in:
parent
a7e634d098
commit
9bba701d6c
@ -143,7 +143,6 @@ public class TraktController : ControllerBase
|
||||
/// <response code="200">Item rated successfully.</response>
|
||||
/// <returns>A <see cref="TraktSyncResponse"/>.</returns>
|
||||
[HttpPost("Users/{userId}/Items/{itemId}/Rate")]
|
||||
[Authorize(Policy = "DefaultAuthorization")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<TraktSyncResponse>> TraktRateItem([FromRoute] string userId, [FromRoute] Guid itemId, [FromQuery] int rating)
|
||||
{
|
||||
@ -167,7 +166,6 @@ public class TraktController : ControllerBase
|
||||
/// <response code="200">Recommended movies returned.</response>
|
||||
/// <returns>A <see cref="List{TraktMovie}"/> with recommended movies.</returns>
|
||||
[HttpPost("Users/{userId}/RecommendedMovies")]
|
||||
[Authorize(Policy = "DefaultAuthorization")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<List<TraktMovie>>> RecommendedTraktMovies([FromRoute] string userId)
|
||||
{
|
||||
@ -181,7 +179,6 @@ public class TraktController : ControllerBase
|
||||
/// <response code="200">Recommended shows returned.</response>
|
||||
/// <returns>A <see cref="List{TraktShow}"/> with recommended movies.</returns>
|
||||
[HttpPost("Users/{userId}/RecommendedShows")]
|
||||
[Authorize(Policy = "DefaultAuthorization")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<List<TraktShow>>> RecommendedTraktShows([FromRoute] string userId)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma warning disable CA1819
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
using Trakt.Model;
|
||||
@ -26,7 +27,7 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
public TraktUser[] TraktUsers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a user to the trakt users.
|
||||
/// Adds a user to the trakt.tv users.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user id.</param>
|
||||
public void AddUser(string userId)
|
||||
@ -50,4 +51,13 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
traktUsers.RemoveAll(user => user.LinkedMbUserId == userId);
|
||||
TraktUsers = traktUsers.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all trakt.tv users.
|
||||
/// </summary>
|
||||
/// <returns>IReadonlyList{TraktUser} with all trakt users.</returns>
|
||||
public IReadOnlyList<TraktUser> GetAllTraktUsers()
|
||||
{
|
||||
return TraktUsers.ToList();
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ internal class LibraryManagerEventsHelper : IDisposable
|
||||
_queueTimer.Change(TimeSpan.FromMilliseconds(10000), Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
|
||||
var users = Plugin.Instance.PluginConfiguration.TraktUsers;
|
||||
var users = Plugin.Instance.PluginConfiguration.GetAllTraktUsers();
|
||||
|
||||
if (users == null || users.Length == 0)
|
||||
if (users == null || users.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -124,8 +124,9 @@ internal class LibraryManagerEventsHelper : IDisposable
|
||||
var queuedShowDeletes = new List<LibraryEvent>();
|
||||
var queuedShowAdds = new List<LibraryEvent>();
|
||||
var queuedShowUpdates = new List<LibraryEvent>();
|
||||
var traktUsers = Plugin.Instance.PluginConfiguration.GetAllTraktUsers();
|
||||
|
||||
foreach (var traktUser in Plugin.Instance.PluginConfiguration.TraktUsers)
|
||||
foreach (var traktUser in traktUsers)
|
||||
{
|
||||
var traktUserGuid = new Guid(traktUser.LinkedMbUserId);
|
||||
|
||||
|
@ -19,12 +19,13 @@ internal static class UserHelper
|
||||
|
||||
public static TraktUser GetTraktUser(Guid userGuid)
|
||||
{
|
||||
if (Plugin.Instance.PluginConfiguration.TraktUsers == null)
|
||||
var traktUsers = Plugin.Instance.PluginConfiguration.GetAllTraktUsers();
|
||||
if (traktUsers.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Plugin.Instance.PluginConfiguration.TraktUsers.FirstOrDefault(user =>
|
||||
return traktUsers.FirstOrDefault(user =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(user.LinkedMbUserId))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user