update connect link text

pull/702/head
Luke Pulverenti 10 years ago
parent 52aad5466a
commit 6dc9b16966

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace MediaBrowser.Api
{
[Route("/Users/{Id}/Connect/Link", "POST", Summary = "Creates a Connect link for a user")]
public class CreateConnectLink : IReturnVoid
public class CreateConnectLink : IReturn<UserLinkResult>
{
[ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
public string Id { get; set; }
@ -32,11 +32,9 @@ namespace MediaBrowser.Api
_connectManager = connectManager;
}
public void Post(CreateConnectLink request)
public object Post(CreateConnectLink request)
{
var task = _connectManager.LinkUser(request.Id, request.ConnectUsername);
Task.WaitAll(task);
return _connectManager.LinkUser(request.Id, request.ConnectUsername);
}
public void Delete(DeleteConnectLink request)

@ -1,20 +0,0 @@

namespace MediaBrowser.Controller.Connect
{
public class ConnectInvitationRequest
{
public string LocalUserId { get; set; }
public string Username { get; set; }
public string RequesterUserId { get; set; }
public ConnectUserType Type { get; set; }
}
public enum ConnectUserType
{
LinkedUser = 1,
Guest = 2
}
}

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MediaBrowser.Controller.Connect
{
public class ConnectUser

@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Connect
/// <param name="userId">The user identifier.</param>
/// <param name="connectUsername">The connect username.</param>
/// <returns>Task.</returns>
Task LinkUser(string userId, string connectUsername);
Task<UserLinkResult> LinkUser(string userId, string connectUsername);
/// <summary>
/// Removes the link.

@ -0,0 +1,8 @@

namespace MediaBrowser.Controller.Connect
{
public class UserLinkResult
{
public bool IsPending { get; set; }
}
}

@ -99,9 +99,9 @@
<Compile Include="Collections\CollectionCreationOptions.cs" />
<Compile Include="Collections\CollectionEvents.cs" />
<Compile Include="Collections\ICollectionManager.cs" />
<Compile Include="Connect\ConnectInvitationRequest.cs" />
<Compile Include="Connect\ConnectUser.cs" />
<Compile Include="Connect\IConnectManager.cs" />
<Compile Include="Connect\UserLinkResult.cs" />
<Compile Include="Dlna\ControlRequest.cs" />
<Compile Include="Dlna\ControlResponse.cs" />
<Compile Include="Dlna\DlnaIconResponse.cs" />

@ -6,6 +6,7 @@ using MediaBrowser.Controller.Connect;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Security;
using MediaBrowser.Model.Connect;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization;
@ -266,7 +267,7 @@ namespace MediaBrowser.Server.Implementations.Connect
return "https://connect.mediabrowser.tv/service/" + handler;
}
public async Task LinkUser(string userId, string connectUsername)
public async Task<UserLinkResult> LinkUser(string userId, string connectUsername)
{
if (string.IsNullOrWhiteSpace(connectUsername))
{
@ -313,17 +314,24 @@ namespace MediaBrowser.Server.Implementations.Connect
SetServerAccessToken(options);
var result = new UserLinkResult();
// No need to examine the response
using (var stream = (await _httpClient.Post(options).ConfigureAwait(false)).Content)
{
var response = _json.DeserializeFromStream<ServerUserAuthorizationResponse>(stream);
result.IsPending = string.Equals(response.AcceptStatus, "waiting", StringComparison.OrdinalIgnoreCase);
}
user.ConnectAccessKey = accessToken;
user.ConnectUserName = connectUser.Name;
user.ConnectUserId = connectUser.Id;
user.ConnectLinkType = UserLinkType.LinkedUser;
await user.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
return result;
}
public Task RemoveLink(string userId)
@ -378,6 +386,7 @@ namespace MediaBrowser.Server.Implementations.Connect
user.ConnectAccessKey = null;
user.ConnectUserName = null;
user.ConnectUserId = null;
user.ConnectLinkType = UserLinkType.LinkedUser;
await user.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
}

@ -28,6 +28,13 @@ namespace MediaBrowser.Server.Implementations.Connect
public class ServerUserAuthorizationResponse
{
public string Id { get; set; }
public string ServerId { get; set; }
public string UserId { get; set; }
public string AccessToken { get; set; }
public string DateCreated { get; set; }
public bool IsActive { get; set; }
public string AcceptStatus { get; set; }
public string UserType { get; set; }
}
}

@ -453,7 +453,8 @@
"MessageYouHaveAnActiveRecurringMembership": "You have an active {0} membership. You can upgrade your plan using the options below.",
"ButtonDelete": "Delete",
"HeaderMediaBrowserAccountAdded": "Media Browser Account Added",
"MessageMediaBrowserAccontAdded": "A Media Browser account has been added to this user. An email will be sent to the owner of the account. The invitation will need to be confirmed by clicking a link within the email.",
"MessageMediaBrowserAccountAdded": "The Media Browser account has been successfully linked to this user.",
"MessagePendingMediaBrowserAccountAdded": "A Media Browser account has been linked to this user. An email will be sent to the owner of the account. The invitation will need to be confirmed by clicking a link within the email.",
"HeaderMediaBrowserAccountRemoved": "Media Browser Account Removed",
"MessageMediaBrowserAccontRemoved": "The Media Browser account has been removed from this user.",
"TooltipLinkedToMediaBrowserConnect": "Linked to Media Browser Connect"

@ -684,6 +684,7 @@
"OptionPlainVideoItemsHelp": "If enabled, all videos are represented in DIDL as \"object.item.videoItem\" instead of a more specific type, such as \"object.item.videoItem.movie\".",
"LabelSupportedMediaTypes": "Supported Media Types:",
"TabIdentification": "Identification",
"HeaderIdentification": "Identification",
"TabDirectPlay": "Direct Play",
"TabContainers": "Containers",
"TabCodecs": "Codecs",

Loading…
Cancel
Save