mirror of https://github.com/jellyfin/jellyfin.git
make additional classes portable
This commit is contained in:
parent
e8c70da2b6
commit
15ebff2b3a
|
@ -187,6 +187,7 @@
|
||||||
<Compile Include="Session\SessionManager.cs" />
|
<Compile Include="Session\SessionManager.cs" />
|
||||||
<Compile Include="Session\SessionWebSocketListener.cs" />
|
<Compile Include="Session\SessionWebSocketListener.cs" />
|
||||||
<Compile Include="Session\WebSocketController.cs" />
|
<Compile Include="Session\WebSocketController.cs" />
|
||||||
|
<Compile Include="Social\SharingManager.cs" />
|
||||||
<Compile Include="Sorting\AiredEpisodeOrderComparer.cs" />
|
<Compile Include="Sorting\AiredEpisodeOrderComparer.cs" />
|
||||||
<Compile Include="Sorting\AirTimeComparer.cs" />
|
<Compile Include="Sorting\AirTimeComparer.cs" />
|
||||||
<Compile Include="Sorting\AlbumArtistComparer.cs" />
|
<Compile Include="Sorting\AlbumArtistComparer.cs" />
|
||||||
|
|
|
@ -143,6 +143,7 @@
|
||||||
<Compile Include="Net\IUdpSocket.cs" />
|
<Compile Include="Net\IUdpSocket.cs" />
|
||||||
<Compile Include="Net\SocketReceiveResult.cs" />
|
<Compile Include="Net\SocketReceiveResult.cs" />
|
||||||
<Compile Include="Services\IHttpResult.cs" />
|
<Compile Include="Services\IHttpResult.cs" />
|
||||||
|
<Compile Include="Social\ISharingRepository.cs" />
|
||||||
<Compile Include="System\IEnvironmentInfo.cs" />
|
<Compile Include="System\IEnvironmentInfo.cs" />
|
||||||
<Compile Include="Text\ITextEncoding.cs" />
|
<Compile Include="Text\ITextEncoding.cs" />
|
||||||
<Compile Include="Extensions\LinqExtensions.cs" />
|
<Compile Include="Extensions\LinqExtensions.cs" />
|
||||||
|
|
|
@ -134,8 +134,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
base.OnConfigLoad();
|
base.OnConfigLoad();
|
||||||
|
|
||||||
Config.HandlerFactoryPath = null;
|
Config.HandlerFactoryPath = null;
|
||||||
|
|
||||||
Config.MetadataRedirectPath = "metadata";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices)
|
protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices)
|
||||||
|
@ -574,7 +572,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
httpRes.StatusCode = 302;
|
httpRes.StatusCode = 302;
|
||||||
httpRes.AddHeader(HttpHeaders.Location, url);
|
httpRes.AddHeader(HttpHeaders.Location, url);
|
||||||
httpRes.EndRequest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,6 @@
|
||||||
<Compile Include="Persistence\IDbConnector.cs" />
|
<Compile Include="Persistence\IDbConnector.cs" />
|
||||||
<Compile Include="Persistence\MediaStreamColumns.cs" />
|
<Compile Include="Persistence\MediaStreamColumns.cs" />
|
||||||
<Compile Include="Serialization\JsonSerializer.cs" />
|
<Compile Include="Serialization\JsonSerializer.cs" />
|
||||||
<Compile Include="Social\SharingManager.cs" />
|
|
||||||
<Compile Include="Social\SharingRepository.cs" />
|
<Compile Include="Social\SharingRepository.cs" />
|
||||||
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
|
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
|
||||||
<Compile Include="Notifications\SqliteNotificationsRepository.cs" />
|
<Compile Include="Notifications\SqliteNotificationsRepository.cs" />
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Social
|
namespace MediaBrowser.Server.Implementations.Social
|
||||||
{
|
{
|
||||||
public class SharingRepository : BaseSqliteRepository
|
public class SharingRepository : BaseSqliteRepository, ISharingRepository
|
||||||
{
|
{
|
||||||
public SharingRepository(ILogManager logManager, IApplicationPaths appPaths, IDbConnector dbConnector)
|
public SharingRepository(ILogManager logManager, IApplicationPaths appPaths, IDbConnector dbConnector)
|
||||||
: base(logManager, dbConnector)
|
: base(logManager, dbConnector)
|
||||||
|
|
|
@ -114,6 +114,7 @@ using Emby.Server.Implementations.Playlists;
|
||||||
using Emby.Server.Implementations.Security;
|
using Emby.Server.Implementations.Security;
|
||||||
using Emby.Server.Implementations.ServerManager;
|
using Emby.Server.Implementations.ServerManager;
|
||||||
using Emby.Server.Implementations.Session;
|
using Emby.Server.Implementations.Session;
|
||||||
|
using Emby.Server.Implementations.Social;
|
||||||
using Emby.Server.Implementations.Sync;
|
using Emby.Server.Implementations.Sync;
|
||||||
using Emby.Server.Implementations.TV;
|
using Emby.Server.Implementations.TV;
|
||||||
using Emby.Server.Implementations.Updates;
|
using Emby.Server.Implementations.Updates;
|
||||||
|
|
Loading…
Reference in New Issue