diff options
7 files changed, 4 insertions, 105 deletions
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 806702dfd..f5c157234 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -187,6 +187,7 @@ <Compile Include="Session\SessionManager.cs" /> <Compile Include="Session\SessionWebSocketListener.cs" /> <Compile Include="Session\WebSocketController.cs" /> + <Compile Include="Social\SharingManager.cs" /> <Compile Include="Sorting\AiredEpisodeOrderComparer.cs" /> <Compile Include="Sorting\AirTimeComparer.cs" /> <Compile Include="Sorting\AlbumArtistComparer.cs" /> diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index ee7582619..abf07e1dc 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -143,6 +143,7 @@ <Compile Include="Net\IUdpSocket.cs" /> <Compile Include="Net\SocketReceiveResult.cs" /> <Compile Include="Services\IHttpResult.cs" /> + <Compile Include="Social\ISharingRepository.cs" /> <Compile Include="System\IEnvironmentInfo.cs" /> <Compile Include="Text\ITextEncoding.cs" /> <Compile Include="Extensions\LinqExtensions.cs" /> diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 7ef8c464e..5d9d05034 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 4096d71dc..3d38c2e3c 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -146,7 +146,6 @@ <Compile Include="Persistence\IDbConnector.cs" /> <Compile Include="Persistence\MediaStreamColumns.cs" /> <Compile Include="Serialization\JsonSerializer.cs" /> - <Compile Include="Social\SharingManager.cs" /> <Compile Include="Social\SharingRepository.cs" /> <Compile Include="Persistence\SqliteFileOrganizationRepository.cs" /> <Compile Include="Notifications\SqliteNotificationsRepository.cs" /> diff --git a/MediaBrowser.Server.Implementations/Social/SharingManager.cs b/MediaBrowser.Server.Implementations/Social/SharingManager.cs deleted file mode 100644 index 0bab7a70d..000000000 --- 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<SocialShareInfo> 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 c4243c1a7..dec43e4cb 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 c0f184bef..1c811ed11 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; |
