mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
consolidate connect calls
This commit is contained in:
parent
9991360d8a
commit
9ad7d5d1a9
@ -5,15 +5,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MediaBrowser.Api
|
namespace MediaBrowser.Api
|
||||||
{
|
{
|
||||||
[Route("/Users/{Id}/Connect/Info", "GET", Summary = "Gets connect info for a user")]
|
|
||||||
public class GetConnectUserInfo : IReturn<ConnectUserLink>
|
|
||||||
{
|
|
||||||
[ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
||||||
public string Id { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[Route("/Users/{Id}/Connect/Link", "POST", Summary = "Creates a Connect link for a user")]
|
[Route("/Users/{Id}/Connect/Link", "POST", Summary = "Creates a Connect link for a user")]
|
||||||
public class CreateConnectLink : IReturn<ConnectUserLink>
|
public class CreateConnectLink : IReturnVoid
|
||||||
{
|
{
|
||||||
[ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
[ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
@ -39,13 +32,6 @@ namespace MediaBrowser.Api
|
|||||||
_connectManager = connectManager;
|
_connectManager = connectManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetConnectUserInfo request)
|
|
||||||
{
|
|
||||||
var result = _connectManager.GetUserInfo(request.Id);
|
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Post(CreateConnectLink request)
|
public void Post(CreateConnectLink request)
|
||||||
{
|
{
|
||||||
var task = _connectManager.LinkUser(request.Id, request.ConnectUsername);
|
var task = _connectManager.LinkUser(request.Id, request.ConnectUsername);
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
namespace MediaBrowser.Controller.Connect
|
|
||||||
{
|
|
||||||
public class ConnectUserLink
|
|
||||||
{
|
|
||||||
public string Username { get; set; }
|
|
||||||
public string UserId { get; set; }
|
|
||||||
public string LocalUserId { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,13 +10,6 @@ namespace MediaBrowser.Controller.Connect
|
|||||||
/// <value>The wan API address.</value>
|
/// <value>The wan API address.</value>
|
||||||
string WanApiAddress { get; }
|
string WanApiAddress { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the user information.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="userId">The user identifier.</param>
|
|
||||||
/// <returns>ConnectUserInfo.</returns>
|
|
||||||
ConnectUserLink GetUserInfo(string userId);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Links the user.
|
/// Links the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Connect;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -34,6 +35,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
public string ConnectUserName { get; set; }
|
public string ConnectUserName { get; set; }
|
||||||
public string ConnectUserId { get; set; }
|
public string ConnectUserId { get; set; }
|
||||||
|
public UserLinkType ConnectLinkType { get; set; }
|
||||||
public string ConnectAccessKey { get; set; }
|
public string ConnectAccessKey { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -101,7 +101,6 @@
|
|||||||
<Compile Include="Collections\ICollectionManager.cs" />
|
<Compile Include="Collections\ICollectionManager.cs" />
|
||||||
<Compile Include="Connect\ConnectInvitationRequest.cs" />
|
<Compile Include="Connect\ConnectInvitationRequest.cs" />
|
||||||
<Compile Include="Connect\ConnectUser.cs" />
|
<Compile Include="Connect\ConnectUser.cs" />
|
||||||
<Compile Include="Connect\ConnectUserLink.cs" />
|
|
||||||
<Compile Include="Connect\IConnectManager.cs" />
|
<Compile Include="Connect\IConnectManager.cs" />
|
||||||
<Compile Include="Dlna\ControlRequest.cs" />
|
<Compile Include="Dlna\ControlRequest.cs" />
|
||||||
<Compile Include="Dlna\ControlResponse.cs" />
|
<Compile Include="Dlna\ControlResponse.cs" />
|
||||||
|
@ -188,6 +188,9 @@
|
|||||||
<Compile Include="..\MediaBrowser.Model\Configuration\XbmcMetadataOptions.cs">
|
<Compile Include="..\MediaBrowser.Model\Configuration\XbmcMetadataOptions.cs">
|
||||||
<Link>Configuration\XbmcMetadataOptions.cs</Link>
|
<Link>Configuration\XbmcMetadataOptions.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\Connect\UserLinkType.cs">
|
||||||
|
<Link>Connect\UserLinkType.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\Dlna\AudioOptions.cs">
|
<Compile Include="..\MediaBrowser.Model\Dlna\AudioOptions.cs">
|
||||||
<Link>Dlna\AudioOptions.cs</Link>
|
<Link>Dlna\AudioOptions.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -151,6 +151,9 @@
|
|||||||
<Compile Include="..\MediaBrowser.Model\Configuration\XbmcMetadataOptions.cs">
|
<Compile Include="..\MediaBrowser.Model\Configuration\XbmcMetadataOptions.cs">
|
||||||
<Link>Configuration\XbmcMetadataOptions.cs</Link>
|
<Link>Configuration\XbmcMetadataOptions.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\mediabrowser.model\connect\UserLinkType.cs">
|
||||||
|
<Link>Connect\UserLinkType.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\Dlna\AudioOptions.cs">
|
<Compile Include="..\MediaBrowser.Model\Dlna\AudioOptions.cs">
|
||||||
<Link>Dlna\AudioOptions.cs</Link>
|
<Link>Dlna\AudioOptions.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
15
MediaBrowser.Model/Connect/UserLinkType.cs
Normal file
15
MediaBrowser.Model/Connect/UserLinkType.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
namespace MediaBrowser.Model.Connect
|
||||||
|
{
|
||||||
|
public enum UserLinkType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The linked user
|
||||||
|
/// </summary>
|
||||||
|
LinkedUser = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// The guest
|
||||||
|
/// </summary>
|
||||||
|
Guest = 2
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,10 @@
|
|||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Connect;
|
||||||
|
using MediaBrowser.Model.Extensions;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using MediaBrowser.Model.Extensions;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Dto
|
namespace MediaBrowser.Model.Dto
|
||||||
{
|
{
|
||||||
@ -19,6 +20,22 @@ namespace MediaBrowser.Model.Dto
|
|||||||
/// <value>The name.</value>
|
/// <value>The name.</value>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name of the connect user.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name of the connect user.</value>
|
||||||
|
public string ConnectUserName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the connect user identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The connect user identifier.</value>
|
||||||
|
public string ConnectUserId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the type of the connect link.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The type of the connect link.</value>
|
||||||
|
public UserLinkType ConnectLinkType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the id.
|
/// Gets or sets the id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
<Compile Include="Configuration\ChapterOptions.cs" />
|
<Compile Include="Configuration\ChapterOptions.cs" />
|
||||||
<Compile Include="Configuration\XbmcMetadataOptions.cs" />
|
<Compile Include="Configuration\XbmcMetadataOptions.cs" />
|
||||||
<Compile Include="Configuration\SubtitlePlaybackMode.cs" />
|
<Compile Include="Configuration\SubtitlePlaybackMode.cs" />
|
||||||
|
<Compile Include="Connect\UserLinkType.cs" />
|
||||||
<Compile Include="Drawing\ImageOrientation.cs" />
|
<Compile Include="Drawing\ImageOrientation.cs" />
|
||||||
<Compile Include="Dto\StreamOptions.cs" />
|
<Compile Include="Dto\StreamOptions.cs" />
|
||||||
<Compile Include="FileOrganization\AutoOrganizeOptions.cs" />
|
<Compile Include="FileOrganization\AutoOrganizeOptions.cs" />
|
||||||
|
@ -261,18 +261,6 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectUserLink GetUserInfo(string userId)
|
|
||||||
{
|
|
||||||
var user = GetUser(userId);
|
|
||||||
|
|
||||||
return new ConnectUserLink
|
|
||||||
{
|
|
||||||
LocalUserId = user.Id.ToString("N"),
|
|
||||||
Username = user.ConnectUserName,
|
|
||||||
UserId = user.ConnectUserId
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetConnectUrl(string handler)
|
private string GetConnectUrl(string handler)
|
||||||
{
|
{
|
||||||
return "https://connect.mediabrowser.tv/service/" + handler;
|
return "https://connect.mediabrowser.tv/service/" + handler;
|
||||||
|
@ -86,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<GenericEventArgs<User>> UserUpdated;
|
public event EventHandler<GenericEventArgs<User>> UserUpdated;
|
||||||
public event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
|
public event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when [user updated].
|
/// Called when [user updated].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -137,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
{
|
{
|
||||||
return GetUserById(new Guid(id));
|
return GetUserById(new Guid(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Initialize()
|
public async Task Initialize()
|
||||||
{
|
{
|
||||||
Users = await LoadUsers().ConfigureAwait(false);
|
Users = await LoadUsers().ConfigureAwait(false);
|
||||||
@ -260,7 +260,10 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
HasConfiguredPassword = hasConfiguredDefaultPassword,
|
HasConfiguredPassword = hasConfiguredDefaultPassword,
|
||||||
LastActivityDate = user.LastActivityDate,
|
LastActivityDate = user.LastActivityDate,
|
||||||
LastLoginDate = user.LastLoginDate,
|
LastLoginDate = user.LastLoginDate,
|
||||||
Configuration = user.Configuration
|
Configuration = user.Configuration,
|
||||||
|
ConnectLinkType = user.ConnectLinkType,
|
||||||
|
ConnectUserId = user.ConnectUserId,
|
||||||
|
ConnectUserName = user.ConnectUserName
|
||||||
};
|
};
|
||||||
|
|
||||||
var image = user.GetImageInfo(ImageType.Primary, 0);
|
var image = user.GetImageInfo(ImageType.Primary, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user