From 15ebff2b3a738855d6c35fafc37d40a72293eef8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 8 Nov 2016 17:28:04 -0500 Subject: [PATCH] make additional classes portable --- .../Emby.Server.Implementations.csproj | 1 + MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + .../HttpServer/HttpListenerHost.cs | 3 - ...MediaBrowser.Server.Implementations.csproj | 1 - .../Social/SharingManager.cs | 100 ------------------ .../Social/SharingRepository.cs | 2 +- .../ApplicationHost.cs | 1 + 7 files changed, 4 insertions(+), 105 deletions(-) delete mode 100644 MediaBrowser.Server.Implementations/Social/SharingManager.cs diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 806702dfd3..f5c1572341 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -187,6 +187,7 @@ + diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index ee75826198..abf07e1dce 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -143,6 +143,7 @@ + diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 7ef8c464e2..5d9d050344 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -134,8 +134,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer base.OnConfigLoad(); Config.HandlerFactoryPath = null; - - Config.MetadataRedirectPath = "metadata"; } protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices) @@ -574,7 +572,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer { httpRes.StatusCode = 302; httpRes.AddHeader(HttpHeaders.Location, url); - httpRes.EndRequest(); } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 4096d71dc6..3d38c2e3ce 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -146,7 +146,6 @@ - diff --git a/MediaBrowser.Server.Implementations/Social/SharingManager.cs b/MediaBrowser.Server.Implementations/Social/SharingManager.cs deleted file mode 100644 index 0bab7a70d7..0000000000 --- a/MediaBrowser.Server.Implementations/Social/SharingManager.cs +++ /dev/null @@ -1,100 +0,0 @@ -using MediaBrowser.Common.Extensions; -using MediaBrowser.Controller; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Social; -using System; -using System.Threading.Tasks; - -namespace MediaBrowser.Server.Implementations.Social -{ - public class SharingManager : ISharingManager - { - private readonly SharingRepository _repository; - private readonly IServerConfigurationManager _config; - private readonly ILibraryManager _libraryManager; - private readonly IServerApplicationHost _appHost; - - public SharingManager(SharingRepository repository, IServerConfigurationManager config, ILibraryManager libraryManager, IServerApplicationHost appHost) - { - _repository = repository; - _config = config; - _libraryManager = libraryManager; - _appHost = appHost; - } - - public async Task CreateShare(string itemId, string userId) - { - if (string.IsNullOrWhiteSpace(itemId)) - { - throw new ArgumentNullException("itemId"); - } - if (string.IsNullOrWhiteSpace(userId)) - { - throw new ArgumentNullException("userId"); - } - - var item = _libraryManager.GetItemById(itemId); - - if (item == null) - { - throw new ResourceNotFoundException(); - } - - var externalUrl = (await _appHost.GetSystemInfo().ConfigureAwait(false)).WanAddress; - - if (string.IsNullOrWhiteSpace(externalUrl)) - { - throw new InvalidOperationException("No external server address is currently available."); - } - - var info = new SocialShareInfo - { - Id = Guid.NewGuid().ToString("N"), - ExpirationDate = DateTime.UtcNow.AddDays(_config.Configuration.SharingExpirationDays), - ItemId = itemId, - UserId = userId - }; - - AddShareInfo(info, externalUrl); - - await _repository.CreateShare(info).ConfigureAwait(false); - - return info; - } - - private string GetTitle(BaseItem item) - { - return item.Name; - } - - public SocialShareInfo GetShareInfo(string id) - { - var info = _repository.GetShareInfo(id); - - AddShareInfo(info, _appHost.GetSystemInfo().Result.WanAddress); - - return info; - } - - private void AddShareInfo(SocialShareInfo info, string externalUrl) - { - info.ImageUrl = externalUrl + "/Social/Shares/Public/" + info.Id + "/Image"; - info.Url = externalUrl + "/emby/web/shared.html?id=" + info.Id; - - var item = _libraryManager.GetItemById(info.ItemId); - - if (item != null) - { - info.Overview = item.Overview; - info.Name = GetTitle(item); - } - } - - public Task DeleteShare(string id) - { - return _repository.DeleteShare(id); - } - } -} diff --git a/MediaBrowser.Server.Implementations/Social/SharingRepository.cs b/MediaBrowser.Server.Implementations/Social/SharingRepository.cs index c4243c1a76..dec43e4cbb 100644 --- a/MediaBrowser.Server.Implementations/Social/SharingRepository.cs +++ b/MediaBrowser.Server.Implementations/Social/SharingRepository.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Social { - public class SharingRepository : BaseSqliteRepository + public class SharingRepository : BaseSqliteRepository, ISharingRepository { public SharingRepository(ILogManager logManager, IApplicationPaths appPaths, IDbConnector dbConnector) : base(logManager, dbConnector) diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index c0f184befe..1c811ed113 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -114,6 +114,7 @@ using Emby.Server.Implementations.Playlists; using Emby.Server.Implementations.Security; using Emby.Server.Implementations.ServerManager; using Emby.Server.Implementations.Session; +using Emby.Server.Implementations.Social; using Emby.Server.Implementations.Sync; using Emby.Server.Implementations.TV; using Emby.Server.Implementations.Updates;