mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
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
This commit is contained in:
parent
83ee6427d8
commit
ec9aac61dd
9 changed files with 59 additions and 11 deletions
|
@ -105,7 +105,7 @@ namespace Ombi.Core.Migration.Migrations
|
||||||
con.AlterTable("EmbyContent", "ADD", "AddedAt", true, "VARCHAR(50)");
|
con.AlterTable("EmbyContent", "ADD", "AddedAt", true, "VARCHAR(50)");
|
||||||
con.AlterTable("EmbyEpisodes", "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)");
|
con.AlterTable("PlexContent", "ADD", "AddedAt", true, "VARCHAR(100)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace Ombi.Core.SettingModels
|
||||||
public bool UsersCanViewOnlyOwnRequests { get; set; }
|
public bool UsersCanViewOnlyOwnRequests { get; set; }
|
||||||
public bool UsersCanViewOnlyOwnIssues { get; set; }
|
public bool UsersCanViewOnlyOwnIssues { get; set; }
|
||||||
public bool BypassRequestLimit { get; set; }
|
public bool BypassRequestLimit { get; set; }
|
||||||
|
public bool ViewUsers { get; set; }
|
||||||
|
|
||||||
// Features
|
// Features
|
||||||
public bool RecentlyAddedNotification { get; set; }
|
public bool RecentlyAddedNotification { get; set; }
|
||||||
|
|
|
@ -73,6 +73,9 @@ namespace Ombi.Helpers.Permissions
|
||||||
UsersCanViewOnlyOwnIssues = 2048,
|
UsersCanViewOnlyOwnIssues = 2048,
|
||||||
|
|
||||||
[Display(Name = "Bypass the request limit")]
|
[Display(Name = "Bypass the request limit")]
|
||||||
BypassRequestLimit = 4096
|
BypassRequestLimit = 4096,
|
||||||
|
|
||||||
|
[Display(Name = "User can see who requested")]
|
||||||
|
ViewUsers = 8192
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -149,6 +149,12 @@ namespace Ombi.Services.Jobs
|
||||||
connection.Dispose();
|
connection.Dispose();
|
||||||
return media;
|
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)
|
if (item == null)
|
||||||
{
|
{
|
||||||
|
@ -255,6 +261,13 @@ namespace Ombi.Services.Jobs
|
||||||
return media;
|
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)
|
if (item == null)
|
||||||
{
|
{
|
||||||
// Doesn't exist, insert it
|
// Doesn't exist, insert it
|
||||||
|
|
|
@ -81,6 +81,7 @@ namespace Ombi.Services.Jobs
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check it this episode exists
|
// Check it this episode exists
|
||||||
var item = Repo.Custom(connection =>
|
var item = Repo.Custom(connection =>
|
||||||
{
|
{
|
||||||
|
@ -93,6 +94,15 @@ namespace Ombi.Services.Jobs
|
||||||
return media;
|
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)
|
if (item == null)
|
||||||
{
|
{
|
||||||
// add it
|
// 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 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 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>();
|
var info = new List<PlexRecentlyAddedModel>();
|
||||||
foreach (var m in filteredMovies)
|
foreach (var m in filteredMovies)
|
||||||
{
|
{
|
||||||
var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, m.ItemId);
|
var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, m.ItemId);
|
||||||
|
if (i.Video == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
info.Add(new PlexRecentlyAddedModel
|
info.Add(new PlexRecentlyAddedModel
|
||||||
{
|
{
|
||||||
Metadata = i,
|
Metadata = i,
|
||||||
|
@ -132,10 +136,14 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
GenerateMovieHtml(info, sb);
|
GenerateMovieHtml(info, sb);
|
||||||
|
|
||||||
info.Clear();
|
info.Clear();
|
||||||
foreach (var t in series)
|
foreach (var t in filteredSeries)
|
||||||
{
|
{
|
||||||
var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, t.ItemId);
|
var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, t.ItemId);
|
||||||
|
if (i.Directory == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
//var ep = filteredEp.Where(x => x.ShowTitle == t.Title);
|
//var ep = filteredEp.Where(x => x.ShowTitle == t.Title);
|
||||||
info.Add(new PlexRecentlyAddedModel
|
info.Add(new PlexRecentlyAddedModel
|
||||||
{
|
{
|
||||||
|
@ -183,6 +191,14 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
AddedAt = DateTime.UtcNow
|
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());
|
var escapedHtml = new string(html.Where(c => !char.IsControl(c)).ToArray());
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -61,7 +62,7 @@ namespace Ombi.Store
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
var result = connection.Query<TableInfo>($"PRAGMA table_info({tableName});");
|
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();
|
connection.Close();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -208,6 +208,8 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
|
|
||||||
var canManageRequest = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests);
|
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
|
var viewModel = dbMovies.Select(movie => new RequestViewModel
|
||||||
{
|
{
|
||||||
ProviderId = movie.ProviderId,
|
ProviderId = movie.ProviderId,
|
||||||
|
@ -224,7 +226,7 @@ namespace Ombi.UI.Modules
|
||||||
Approved = movie.Available || movie.Approved,
|
Approved = movie.Available || movie.Approved,
|
||||||
Title = movie.Title,
|
Title = movie.Title,
|
||||||
Overview = movie.Overview,
|
Overview = movie.Overview,
|
||||||
RequestedUsers = canManageRequest ? movie.AllUsers.ToArray() : new string[] { },
|
RequestedUsers = canManageRequest || allowViewUsers ? movie.AllUsers.ToArray() : new string[] { },
|
||||||
ReleaseYear = movie.ReleaseDate.Year.ToString(),
|
ReleaseYear = movie.ReleaseDate.Year.ToString(),
|
||||||
Available = movie.Available,
|
Available = movie.Available,
|
||||||
Admin = canManageRequest,
|
Admin = canManageRequest,
|
||||||
|
@ -294,6 +296,8 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
|
|
||||||
var canManageRequest = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests);
|
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
|
var viewModel = dbTv.Select(tv => new RequestViewModel
|
||||||
{
|
{
|
||||||
ProviderId = tv.ProviderId,
|
ProviderId = tv.ProviderId,
|
||||||
|
@ -310,7 +314,7 @@ namespace Ombi.UI.Modules
|
||||||
Approved = tv.Available || tv.Approved,
|
Approved = tv.Available || tv.Approved,
|
||||||
Title = tv.Title,
|
Title = tv.Title,
|
||||||
Overview = tv.Overview,
|
Overview = tv.Overview,
|
||||||
RequestedUsers = canManageRequest ? tv.AllUsers.ToArray() : new string[] { },
|
RequestedUsers = canManageRequest || allowViewUsers ? tv.AllUsers.ToArray() : new string[] { },
|
||||||
ReleaseYear = tv.ReleaseDate.Year.ToString(),
|
ReleaseYear = tv.ReleaseDate.Year.ToString(),
|
||||||
Available = tv.Available,
|
Available = tv.Available,
|
||||||
Admin = canManageRequest,
|
Admin = canManageRequest,
|
||||||
|
@ -382,7 +386,6 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
private async Task<Response> GetAlbumRequests()
|
private async Task<Response> GetAlbumRequests()
|
||||||
{
|
{
|
||||||
var settings = PrSettings.GetSettings();
|
|
||||||
var dbAlbum = await Service.GetAllAsync();
|
var dbAlbum = await Service.GetAllAsync();
|
||||||
dbAlbum = dbAlbum.Where(x => x.Type == RequestType.Album);
|
dbAlbum = dbAlbum.Where(x => x.Type == RequestType.Album);
|
||||||
if (Security.HasPermissions(User, Permissions.UsersCanViewOnlyOwnRequests) && !IsAdmin)
|
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>
|
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Ombi.Core.SettingModels.UserManagementSettings>
|
||||||
@Html.Partial("Shared/Partial/_Sidebar")
|
@Html.Partial("Shared/Partial/_Sidebar")
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
@Html.Checkbox(Model.UsersCanViewOnlyOwnIssues, "UsersCanViewOnlyOwnIssues", "Users can only view their own issues")
|
@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.UsersCanViewOnlyOwnRequests, "UsersCanViewOnlyOwnRequests", "Users can only view their own requests")
|
||||||
@Html.Checkbox(Model.BypassRequestLimit, "BypassRequestLimit", "Bypass the request limit")
|
@Html.Checkbox(Model.BypassRequestLimit, "BypassRequestLimit", "Bypass the request limit")
|
||||||
|
@Html.Checkbox(Model.ViewUsers, "ViewUsers", "User can see who made requests")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue