From 6dc9b169666bcfeb2edf3620c0646efa0c29606f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 14 Sep 2014 19:39:06 -0400 Subject: [PATCH] update connect link text --- MediaBrowser.Api/ConnectService.cs | 8 +++----- .../Connect/ConnectInvitationRequest.cs | 20 ------------------- .../Connect/ConnectUser.cs | 7 +------ .../Connect/IConnectManager.cs | 2 +- .../Connect/UserLinkResult.cs | 8 ++++++++ .../MediaBrowser.Controller.csproj | 2 +- .../Connect/ConnectManager.cs | 11 +++++++++- .../Connect/Responses.cs | 9 ++++++++- .../Localization/JavaScript/javascript.json | 3 ++- .../Localization/Server/server.json | 1 + 10 files changed, 35 insertions(+), 36 deletions(-) delete mode 100644 MediaBrowser.Controller/Connect/ConnectInvitationRequest.cs create mode 100644 MediaBrowser.Controller/Connect/UserLinkResult.cs diff --git a/MediaBrowser.Api/ConnectService.cs b/MediaBrowser.Api/ConnectService.cs index 14b04a0bb8..9ea75d4ace 100644 --- a/MediaBrowser.Api/ConnectService.cs +++ b/MediaBrowser.Api/ConnectService.cs @@ -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 { [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) diff --git a/MediaBrowser.Controller/Connect/ConnectInvitationRequest.cs b/MediaBrowser.Controller/Connect/ConnectInvitationRequest.cs deleted file mode 100644 index 91516723bf..0000000000 --- a/MediaBrowser.Controller/Connect/ConnectInvitationRequest.cs +++ /dev/null @@ -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 - } -} diff --git a/MediaBrowser.Controller/Connect/ConnectUser.cs b/MediaBrowser.Controller/Connect/ConnectUser.cs index 2cd14ec7cc..389330cecb 100644 --- a/MediaBrowser.Controller/Connect/ConnectUser.cs +++ b/MediaBrowser.Controller/Connect/ConnectUser.cs @@ -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 diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs index 8bdb76ea41..7c1e14c302 100644 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ b/MediaBrowser.Controller/Connect/IConnectManager.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Connect /// The user identifier. /// The connect username. /// Task. - Task LinkUser(string userId, string connectUsername); + Task LinkUser(string userId, string connectUsername); /// /// Removes the link. diff --git a/MediaBrowser.Controller/Connect/UserLinkResult.cs b/MediaBrowser.Controller/Connect/UserLinkResult.cs new file mode 100644 index 0000000000..4ed57cfc2d --- /dev/null +++ b/MediaBrowser.Controller/Connect/UserLinkResult.cs @@ -0,0 +1,8 @@ + +namespace MediaBrowser.Controller.Connect +{ + public class UserLinkResult + { + public bool IsPending { get; set; } + } +} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index fa10642324..6d881da4f8 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -99,9 +99,9 @@ - + diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 3933b180e2..d92ca8323f 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.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 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(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); } diff --git a/MediaBrowser.Server.Implementations/Connect/Responses.cs b/MediaBrowser.Server.Implementations/Connect/Responses.cs index a3b0369ba1..eeb56d1c91 100644 --- a/MediaBrowser.Server.Implementations/Connect/Responses.cs +++ b/MediaBrowser.Server.Implementations/Connect/Responses.cs @@ -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; } } } diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index f8bb0f1d50..543bcced26 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -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" diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 86dc60c2ee..781b3e927a 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -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",