aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-07-02 01:08:05 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-07-02 01:08:05 -0400
commit67ed8070dcb31eb41be47fefa5ee29bd081e6c47 (patch)
treeb970323190e8268fceec24773bf8f54dd562abfd /MediaBrowser.Server.Implementations
parent91ce8f443713ed8d9c694ef554e183ac954728b2 (diff)
add sharing function
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/Dto/DtoService.cs1
-rw-r--r--MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json5
-rw-r--r--MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs22
-rw-r--r--MediaBrowser.Server.Implementations/Social/SharingManager.cs29
4 files changed, 46 insertions, 11 deletions
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index de63fada0..d147777bd 100644
--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs
+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
@@ -736,6 +736,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
})
.Where(i => i != null)
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
for (var i = 0; i < studios.Count; i++)
diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json
index 254e3c2f3..b82bd29a7 100644
--- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json
+++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json
@@ -813,6 +813,7 @@
"ErrorMessageEmailInUse": "The email address is already in use. Please enter a new email address and try again, or use the forgot password feature.",
"MessageThankYouForConnectSignUp": "Thank you for signing up for Emby Connect. An email will be sent to your address with instructions on how to confirm your new account. Please confirm the account and then return here to sign in.",
"HeaderShare": "Share",
- "ButtonShareHelp": "Only a web page containing media information will be shared. Media files are never shared publicly."
-
+ "ButtonShareHelp": "Share a web page containing media information with social media. Media files are never shared publicly.",
+ "ButtonShare": "Share",
+ "HeaderConfirm": "Confirm"
}
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index ff689ac7f..9778e3c32 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -1,3 +1,4 @@
+using System.Runtime.Serialization;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.LiveTv;
@@ -413,7 +414,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
using (var stream = reader.GetMemoryStream(1))
{
- return _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
+ try
+ {
+ return _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
+ }
+ catch (SerializationException ex)
+ {
+ _logger.ErrorException("Error deserializing item", ex);
+ return null;
+ }
}
}
@@ -696,7 +705,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
while (reader.Read())
{
- list.Add(GetItem(reader));
+ var item = GetItem(reader);
+ if (item != null)
+ {
+ list.Add(item);
+ }
}
if (reader.NextResult() && reader.Read())
@@ -986,6 +999,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
_deleteChildrenCommand.Transaction = transaction;
_deleteChildrenCommand.ExecuteNonQuery();
+ // Delete people
+ _deletePeopleCommand.GetParameter(0).Value = id;
+ _deletePeopleCommand.Transaction = transaction;
+ _deletePeopleCommand.ExecuteNonQuery();
+
// Delete the item
_deleteItemCommand.GetParameter(0).Value = id;
_deleteItemCommand.Transaction = transaction;
diff --git a/MediaBrowser.Server.Implementations/Social/SharingManager.cs b/MediaBrowser.Server.Implementations/Social/SharingManager.cs
index 1c3f35389..326b2893c 100644
--- a/MediaBrowser.Server.Implementations/Social/SharingManager.cs
+++ b/MediaBrowser.Server.Implementations/Social/SharingManager.cs
@@ -55,17 +55,14 @@ namespace MediaBrowser.Server.Implementations.Social
Id = Guid.NewGuid().ToString("N"),
ExpirationDate = DateTime.UtcNow.AddDays(_config.Configuration.SharingExpirationDays),
ItemId = itemId,
- UserId = userId,
- Overview = item.Overview,
- Name = GetTitle(item)
+ UserId = userId
};
- info.ImageUrl = externalUrl + "/Social/Shares/Public/" + info.Id + "/Image";
- info.ImageUrl = externalUrl + "/web/shared.html?id=" + info.Id;
-
+ AddShareInfo(info);
+
await _repository.CreateShare(info).ConfigureAwait(false);
- return GetShareInfo(info.Id);
+ return info;
}
private string GetTitle(BaseItem item)
@@ -77,9 +74,27 @@ namespace MediaBrowser.Server.Implementations.Social
{
var info = _repository.GetShareInfo(id);
+ AddShareInfo(info);
+
return info;
}
+ private void AddShareInfo(SocialShareInfo info)
+ {
+ var externalUrl = _appHost.GetSystemInfo().WanAddress;
+
+ info.ImageUrl = externalUrl + "/Social/Shares/Public/" + info.Id + "/Image";
+ info.Url = externalUrl + "/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);