The Free Software Media System - Server Backend & API
make additional classes portable
Luke Pulverenti15ebff2b3a73
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csprojindex 806702dfd3..f5c1572341 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.csprojindex ee75826198..abf07e1dce 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.csindex 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.HttpServerbase.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.csprojindex 4096d71dc6..3d38c2e3ce 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.csdeleted file mode 100644index 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<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.csindex 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.csindex 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;