consolidate connect calls
This commit is contained in:
parent
9991360d8a
commit
9ad7d5d1a9
|
@ -5,15 +5,8 @@ using System.Threading.Tasks;
|
|||
|
||||
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")]
|
||||
public class CreateConnectLink : IReturn<ConnectUserLink>
|
||||
public class CreateConnectLink : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string Id { get; set; }
|
||||
|
@ -39,13 +32,6 @@ namespace MediaBrowser.Api
|
|||
_connectManager = connectManager;
|
||||
}
|
||||
|
||||
public object Get(GetConnectUserInfo request)
|
||||
{
|
||||
var result = _connectManager.GetUserInfo(request.Id);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
public void Post(CreateConnectLink request)
|
||||
{
|
||||
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>
|
||||
string WanApiAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user information.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user identifier.</param>
|
||||
/// <returns>ConnectUserInfo.</returns>
|
||||
ConnectUserLink GetUserInfo(string userId);
|
||||
|
||||
/// <summary>
|
||||
/// Links the user.
|
||||
/// </summary>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Connect;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
@ -34,6 +35,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
public string ConnectUserName { get; set; }
|
||||
public string ConnectUserId { get; set; }
|
||||
public UserLinkType ConnectLinkType { get; set; }
|
||||
public string ConnectAccessKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -101,7 +101,6 @@
|
|||
<Compile Include="Collections\ICollectionManager.cs" />
|
||||
<Compile Include="Connect\ConnectInvitationRequest.cs" />
|
||||
<Compile Include="Connect\ConnectUser.cs" />
|
||||
<Compile Include="Connect\ConnectUserLink.cs" />
|
||||
<Compile Include="Connect\IConnectManager.cs" />
|
||||
<Compile Include="Dlna\ControlRequest.cs" />
|
||||
<Compile Include="Dlna\ControlResponse.cs" />
|
||||
|
|
|
@ -188,6 +188,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Configuration\XbmcMetadataOptions.cs">
|
||||
<Link>Configuration\XbmcMetadataOptions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Connect\UserLinkType.cs">
|
||||
<Link>Connect\UserLinkType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dlna\AudioOptions.cs">
|
||||
<Link>Dlna\AudioOptions.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -151,6 +151,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Configuration\XbmcMetadataOptions.cs">
|
||||
<Link>Configuration\XbmcMetadataOptions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\mediabrowser.model\connect\UserLinkType.cs">
|
||||
<Link>Connect\UserLinkType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dlna\AudioOptions.cs">
|
||||
<Link>Dlna\AudioOptions.cs</Link>
|
||||
</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.Connect;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
|
@ -19,6 +20,22 @@ namespace MediaBrowser.Model.Dto
|
|||
/// <value>The name.</value>
|
||||
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>
|
||||
/// Gets or sets the id.
|
||||
/// </summary>
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
<Compile Include="Configuration\ChapterOptions.cs" />
|
||||
<Compile Include="Configuration\XbmcMetadataOptions.cs" />
|
||||
<Compile Include="Configuration\SubtitlePlaybackMode.cs" />
|
||||
<Compile Include="Connect\UserLinkType.cs" />
|
||||
<Compile Include="Drawing\ImageOrientation.cs" />
|
||||
<Compile Include="Dto\StreamOptions.cs" />
|
||||
<Compile Include="FileOrganization\AutoOrganizeOptions.cs" />
|
||||
|
|
|
@ -261,18 +261,6 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||
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)
|
||||
{
|
||||
return "https://connect.mediabrowser.tv/service/" + handler;
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
/// </summary>
|
||||
public event EventHandler<GenericEventArgs<User>> UserUpdated;
|
||||
public event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called when [user updated].
|
||||
/// </summary>
|
||||
|
@ -137,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
{
|
||||
return GetUserById(new Guid(id));
|
||||
}
|
||||
|
||||
|
||||
public async Task Initialize()
|
||||
{
|
||||
Users = await LoadUsers().ConfigureAwait(false);
|
||||
|
@ -260,7 +260,10 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
HasConfiguredPassword = hasConfiguredDefaultPassword,
|
||||
LastActivityDate = user.LastActivityDate,
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user