Fixed around the newsletter and a small feature around the permissions/features (#1215)

* fixup! Reset the branch on v2.1.0 tag to get to a shared state between dev and Master.

* typo

* Fixed a bug in the Plex Newsletter

* Another newsletter fix attempt #1163 #1116
pull/1225/head
Jamie 8 years ago committed by GitHub
parent 83ee6427d8
commit ec9aac61dd

@ -105,7 +105,7 @@ namespace Ombi.Core.Migration.Migrations
con.AlterTable("EmbyContent", "ADD", "AddedAt", true, "VARCHAR(50)");
con.AlterTable("EmbyEpisodes", "ADD", "AddedAt", true, "VARCHAR(50)");
con.AlterTable("PlexContent", "ADD", "ItemID", true, "VARCHAR(100)");
con.AlterTable("PlexContent", "ADD", "ItemId", true, "VARCHAR(100)");
con.AlterTable("PlexContent", "ADD", "AddedAt", true, "VARCHAR(100)");
}

@ -38,6 +38,7 @@ namespace Ombi.Core.SettingModels
public bool UsersCanViewOnlyOwnRequests { get; set; }
public bool UsersCanViewOnlyOwnIssues { get; set; }
public bool BypassRequestLimit { get; set; }
public bool ViewUsers { get; set; }
// Features
public bool RecentlyAddedNotification { get; set; }

@ -73,6 +73,9 @@ namespace Ombi.Helpers.Permissions
UsersCanViewOnlyOwnIssues = 2048,
[Display(Name = "Bypass the request limit")]
BypassRequestLimit = 4096
BypassRequestLimit = 4096,
[Display(Name = "User can see who requested")]
ViewUsers = 8192
}
}

@ -115,7 +115,7 @@ namespace Ombi.Services.Jobs
foreach (var item in info.Items)
{
var movieInfo = EmbyApi.GetInformation(item.Id, EmbyMediaType.Movie, embySettings.ApiKey,
embySettings.AdministratorId, embySettings.FullUri).MovieInformation;
embySettings.AdministratorId, embySettings.FullUri).MovieInformation;
ProcessMovies(movieInfo);
}
}
@ -149,6 +149,12 @@ namespace Ombi.Services.Jobs
connection.Dispose();
return media;
});
if (item != null && item.EmbyId != t.Id)
{
// delete this item since the Id has changed
EmbyContent.Delete(item);
item = null;
}
if (item == null)
{
@ -255,6 +261,13 @@ namespace Ombi.Services.Jobs
return media;
});
if (item != null && item.EmbyId != movieInfo.Id)
{
// delete this item since the Id has changed
EmbyContent.Delete(item);
item = null;
}
if (item == null)
{
// Doesn't exist, insert it

@ -81,6 +81,7 @@ namespace Ombi.Services.Jobs
continue;
}
// Check it this episode exists
var item = Repo.Custom(connection =>
{
@ -93,6 +94,15 @@ namespace Ombi.Services.Jobs
return media;
});
if (item != null)
{
if (item.EmbyId != ep.Id) // The id's dont match, delete it
{
Repo.Delete(item);
item = null;
}
}
if (item == null)
{
// add it

@ -117,12 +117,16 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList();
var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList();
var filteredSeries = series.Where(x => recentlyAdded.All(c => c.ProviderId != x.ProviderId)).ToList();
var info = new List<PlexRecentlyAddedModel>();
foreach (var m in filteredMovies)
{
var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, m.ItemId);
if (i.Video == null)
{
continue;
}
info.Add(new PlexRecentlyAddedModel
{
Metadata = i,
@ -132,10 +136,14 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
GenerateMovieHtml(info, sb);
info.Clear();
foreach (var t in series)
foreach (var t in filteredSeries)
{
var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, t.ItemId);
if (i.Directory == null)
{
continue;
}
//var ep = filteredEp.Where(x => x.ShowTitle == t.Title);
info.Add(new PlexRecentlyAddedModel
{
@ -183,6 +191,14 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
AddedAt = DateTime.UtcNow
});
}
foreach (var a in filteredSeries)
{
RecentlyAddedLog.Insert(new RecentlyAddedLog
{
ProviderId = a.ProviderId,
AddedAt = DateTime.UtcNow
});
}
}
var escapedHtml = new string(html.Where(c => !char.IsControl(c)).ToArray());

@ -25,6 +25,7 @@
// ***********************************************************************
#endregion
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
@ -61,7 +62,7 @@ namespace Ombi.Store
{
connection.Open();
var result = connection.Query<TableInfo>($"PRAGMA table_info({tableName});");
if (result.Any(x => x.name == newColumn))
if (result.Any(x => x.name.Equals(newColumn, StringComparison.CurrentCultureIgnoreCase)))
{
connection.Close();
return;

@ -208,6 +208,8 @@ namespace Ombi.UI.Modules
var canManageRequest = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests);
var allowViewUsers = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ViewUsers);
var viewModel = dbMovies.Select(movie => new RequestViewModel
{
ProviderId = movie.ProviderId,
@ -224,7 +226,7 @@ namespace Ombi.UI.Modules
Approved = movie.Available || movie.Approved,
Title = movie.Title,
Overview = movie.Overview,
RequestedUsers = canManageRequest ? movie.AllUsers.ToArray() : new string[] { },
RequestedUsers = canManageRequest || allowViewUsers ? movie.AllUsers.ToArray() : new string[] { },
ReleaseYear = movie.ReleaseDate.Year.ToString(),
Available = movie.Available,
Admin = canManageRequest,
@ -294,6 +296,8 @@ namespace Ombi.UI.Modules
var canManageRequest = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests);
var allowViewUsers = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ViewUsers);
var viewModel = dbTv.Select(tv => new RequestViewModel
{
ProviderId = tv.ProviderId,
@ -310,7 +314,7 @@ namespace Ombi.UI.Modules
Approved = tv.Available || tv.Approved,
Title = tv.Title,
Overview = tv.Overview,
RequestedUsers = canManageRequest ? tv.AllUsers.ToArray() : new string[] { },
RequestedUsers = canManageRequest || allowViewUsers ? tv.AllUsers.ToArray() : new string[] { },
ReleaseYear = tv.ReleaseDate.Year.ToString(),
Available = tv.Available,
Admin = canManageRequest,
@ -382,7 +386,6 @@ namespace Ombi.UI.Modules
private async Task<Response> GetAlbumRequests()
{
var settings = PrSettings.GetSettings();
var dbAlbum = await Service.GetAllAsync();
dbAlbum = dbAlbum.Where(x => x.Type == RequestType.Album);
if (Security.HasPermissions(User, Permissions.UsersCanViewOnlyOwnRequests) && !IsAdmin)

@ -1,4 +1,4 @@
@using Ombi.UI.Helpers
@using Ombi.UI.Helpers
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Ombi.Core.SettingModels.UserManagementSettings>
@Html.Partial("Shared/Partial/_Sidebar")
@ -25,6 +25,7 @@
@Html.Checkbox(Model.UsersCanViewOnlyOwnIssues, "UsersCanViewOnlyOwnIssues", "Users can only view their own issues")
@Html.Checkbox(Model.UsersCanViewOnlyOwnRequests, "UsersCanViewOnlyOwnRequests", "Users can only view their own requests")
@Html.Checkbox(Model.BypassRequestLimit, "BypassRequestLimit", "Bypass the request limit")
@Html.Checkbox(Model.ViewUsers, "ViewUsers", "User can see who made requests")

Loading…
Cancel
Save