|
|
|
@ -14,218 +14,156 @@ namespace Ombi.Notifications
|
|
|
|
|
{
|
|
|
|
|
public class NotificationMessageCurlys
|
|
|
|
|
{
|
|
|
|
|
public void Setup(NotificationOptions opts, MovieRequests req, CustomizationSettings s, UserNotificationPreferences pref)
|
|
|
|
|
{
|
|
|
|
|
LoadIssues(opts);
|
|
|
|
|
|
|
|
|
|
RequestId = req?.Id.ToString();
|
|
|
|
|
ProviderId = req?.TheMovieDbId.ToString() ?? string.Empty;
|
|
|
|
|
string title;
|
|
|
|
|
if (req == null)
|
|
|
|
|
{
|
|
|
|
|
opts.Substitutes.TryGetValue("Title", out title);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
title = req?.Title;
|
|
|
|
|
}
|
|
|
|
|
ApplicationUrl = (s?.ApplicationUrl.HasValue() ?? false) ? s.ApplicationUrl : string.Empty;
|
|
|
|
|
ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s?.ApplicationName;
|
|
|
|
|
RequestedUser = req?.RequestedUser?.UserName;
|
|
|
|
|
if (UserName.IsNullOrEmpty())
|
|
|
|
|
public void SetupNewsletter(CustomizationSettings s)
|
|
|
|
|
{
|
|
|
|
|
// Can be set if it's an issue
|
|
|
|
|
UserName = req?.RequestedUser?.UserName;
|
|
|
|
|
ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s.ApplicationName;
|
|
|
|
|
ApplicationUrl = s?.ApplicationUrl.HasValue() ?? false ? s.ApplicationUrl : string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Alias.IsNullOrEmpty())
|
|
|
|
|
public void Setup(OmbiUser user, CustomizationSettings s)
|
|
|
|
|
{
|
|
|
|
|
// Can be set if it's an issue
|
|
|
|
|
Alias = (req?.RequestedUser?.Alias.HasValue() ?? false) ? req?.RequestedUser?.Alias : req?.RequestedUser?.UserName;
|
|
|
|
|
ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s.ApplicationName;
|
|
|
|
|
ApplicationUrl = s?.ApplicationUrl.HasValue() ?? false ? s.ApplicationUrl : string.Empty;
|
|
|
|
|
RequestedUser = user.UserName;
|
|
|
|
|
Alias = user.UserAlias;
|
|
|
|
|
UserName = user.UserName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pref != null)
|
|
|
|
|
{
|
|
|
|
|
UserPreference = pref.Value.HasValue() ? pref.Value : Alias;
|
|
|
|
|
}
|
|
|
|
|
Title = title;
|
|
|
|
|
RequestedDate = req?.RequestedDate.ToString("D");
|
|
|
|
|
if (Type.IsNullOrEmpty())
|
|
|
|
|
public void Setup(NotificationOptions opts, MovieRequests req, CustomizationSettings s,
|
|
|
|
|
UserNotificationPreferences pref)
|
|
|
|
|
{
|
|
|
|
|
Type = req?.RequestType.Humanize();
|
|
|
|
|
}
|
|
|
|
|
Overview = req?.Overview;
|
|
|
|
|
LoadIssues(opts);
|
|
|
|
|
LoadCommon(req, s, pref);
|
|
|
|
|
LoadTitle(opts, req);
|
|
|
|
|
ProviderId = req?.TheMovieDbId.ToString() ?? string.Empty;
|
|
|
|
|
Year = req?.ReleaseDate.Year.ToString();
|
|
|
|
|
DenyReason = req?.DeniedReason;
|
|
|
|
|
AvailableDate = req?.MarkedAsAvailable?.ToString("D") ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
PosterImage = string.Format((req?.PosterPath ?? string.Empty).StartsWith("/", StringComparison.InvariantCultureIgnoreCase)
|
|
|
|
|
? "https://image.tmdb.org/t/p/w300{0}" : "https://image.tmdb.org/t/p/w300/{0}", req?.PosterPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Overview = req?.Overview;
|
|
|
|
|
AdditionalInformation = opts?.AdditionalInformation ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
PosterImage = $"https://image.tmdb.org/t/p/w300/{req?.PosterPath?.TrimStart('/') ?? string.Empty}";
|
|
|
|
|
CalculateRequestStatus(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Setup(NotificationOptions opts, AlbumRequest req, CustomizationSettings s, UserNotificationPreferences pref)
|
|
|
|
|
public void Setup(NotificationOptions opts, ChildRequests req, CustomizationSettings s,
|
|
|
|
|
UserNotificationPreferences pref)
|
|
|
|
|
{
|
|
|
|
|
LoadIssues(opts);
|
|
|
|
|
LoadCommon(req, s, pref);
|
|
|
|
|
LoadTitle(opts, req);
|
|
|
|
|
ProviderId = req?.ParentRequest?.ExternalProviderId.ToString() ?? string.Empty;
|
|
|
|
|
Year = req?.ParentRequest?.ReleaseDate.Year.ToString();
|
|
|
|
|
Overview = req?.ParentRequest?.Overview;
|
|
|
|
|
AdditionalInformation = opts.AdditionalInformation;
|
|
|
|
|
PosterImage =
|
|
|
|
|
$"https://image.tmdb.org/t/p/w300/{req?.ParentRequest?.PosterPath?.TrimStart('/') ?? string.Empty}";
|
|
|
|
|
|
|
|
|
|
RequestId = req?.Id.ToString();
|
|
|
|
|
ProviderId = req?.ForeignArtistId ?? string.Empty;
|
|
|
|
|
// Generate episode list.
|
|
|
|
|
StringBuilder epSb = new StringBuilder();
|
|
|
|
|
IEnumerable<EpisodeRequests> episodes = req?.SeasonRequests?
|
|
|
|
|
.SelectMany(x => x.Episodes) ?? new List<EpisodeRequests>();
|
|
|
|
|
episodes
|
|
|
|
|
.OrderBy(x => x.EpisodeNumber)
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(ep => epSb.Append($"{ep.EpisodeNumber},"));
|
|
|
|
|
if (epSb.Length > 0) epSb.Remove(epSb.Length - 1, 1);
|
|
|
|
|
EpisodesList = epSb.ToString();
|
|
|
|
|
|
|
|
|
|
string title;
|
|
|
|
|
if (req == null)
|
|
|
|
|
{
|
|
|
|
|
opts.Substitutes.TryGetValue("Title", out title);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
title = req?.Title;
|
|
|
|
|
}
|
|
|
|
|
ApplicationUrl = (s?.ApplicationUrl.HasValue() ?? false) ? s.ApplicationUrl : string.Empty;
|
|
|
|
|
ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s?.ApplicationName;
|
|
|
|
|
RequestedUser = req?.RequestedUser?.UserName;
|
|
|
|
|
if (UserName.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
// Can be set if it's an issue
|
|
|
|
|
UserName = req?.RequestedUser?.UserName;
|
|
|
|
|
// Generate season list.
|
|
|
|
|
StringBuilder seasonSb = new StringBuilder();
|
|
|
|
|
List<SeasonRequests> seasons = req?.SeasonRequests ?? new List<SeasonRequests>();
|
|
|
|
|
seasons
|
|
|
|
|
.OrderBy(x => x.SeasonNumber)
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(ep => seasonSb.Append($"{ep.SeasonNumber},"));
|
|
|
|
|
if (seasonSb.Length > 0) seasonSb.Remove(seasonSb.Length - 1, 1);
|
|
|
|
|
SeasonsList = seasonSb.ToString();
|
|
|
|
|
CalculateRequestStatus(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AvailableDate = req?.MarkedAsAvailable?.ToString("D") ?? string.Empty;
|
|
|
|
|
DenyReason = req?.DeniedReason;
|
|
|
|
|
if (Alias.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
Alias = (req?.RequestedUser?.Alias.HasValue() ?? false) ? req?.RequestedUser?.Alias : req?.RequestedUser?.UserName;
|
|
|
|
|
}
|
|
|
|
|
if (pref != null)
|
|
|
|
|
{
|
|
|
|
|
UserPreference = pref.Value.HasValue() ? pref.Value : Alias;
|
|
|
|
|
}
|
|
|
|
|
Title = title;
|
|
|
|
|
RequestedDate = req?.RequestedDate.ToString("D");
|
|
|
|
|
if (Type.IsNullOrEmpty())
|
|
|
|
|
public void Setup(NotificationOptions opts, AlbumRequest req, CustomizationSettings s,
|
|
|
|
|
UserNotificationPreferences pref)
|
|
|
|
|
{
|
|
|
|
|
Type = req?.RequestType.Humanize();
|
|
|
|
|
}
|
|
|
|
|
LoadIssues(opts);
|
|
|
|
|
LoadCommon(req, s, pref);
|
|
|
|
|
LoadTitle(opts, req);
|
|
|
|
|
ProviderId = req?.ForeignArtistId ?? string.Empty;
|
|
|
|
|
Year = req?.ReleaseDate.Year.ToString();
|
|
|
|
|
PosterImage = (req?.Cover.HasValue() ?? false) ? req.Cover : req?.Disk ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
AdditionalInformation = opts?.AdditionalInformation ?? string.Empty;
|
|
|
|
|
PosterImage = req?.Cover.HasValue() ?? false ? req.Cover : req?.Disk ?? string.Empty;
|
|
|
|
|
CalculateRequestStatus(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetupNewsletter(CustomizationSettings s)
|
|
|
|
|
private void LoadIssues(NotificationOptions opts)
|
|
|
|
|
{
|
|
|
|
|
ApplicationUrl = (s?.ApplicationUrl.HasValue() ?? false) ? s.ApplicationUrl : string.Empty;
|
|
|
|
|
ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s?.ApplicationName;
|
|
|
|
|
IssueDescription = opts.Substitutes.TryGetValue("IssueDescription", out string val) ? val : string.Empty;
|
|
|
|
|
IssueCategory = opts.Substitutes.TryGetValue("IssueCategory", out val) ? val : string.Empty;
|
|
|
|
|
IssueStatus = opts.Substitutes.TryGetValue("IssueStatus", out val) ? val : string.Empty;
|
|
|
|
|
IssueSubject = opts.Substitutes.TryGetValue("IssueSubject", out val) ? val : string.Empty;
|
|
|
|
|
NewIssueComment = opts.Substitutes.TryGetValue("NewIssueComment", out val) ? val : string.Empty;
|
|
|
|
|
UserName = opts.Substitutes.TryGetValue("IssueUser", out val) ? val : string.Empty;
|
|
|
|
|
Alias = opts.Substitutes.TryGetValue("IssueUserAlias", out val) ? val : string.Empty;
|
|
|
|
|
Type = opts.Substitutes.TryGetValue("RequestType", out val) && Enum.TryParse(val, out RequestType type)
|
|
|
|
|
? HumanizeReturnType(type)
|
|
|
|
|
: string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Setup(NotificationOptions opts, ChildRequests req, CustomizationSettings s, UserNotificationPreferences pref)
|
|
|
|
|
private void LoadCommon(BaseRequest req, CustomizationSettings s, UserNotificationPreferences pref)
|
|
|
|
|
{
|
|
|
|
|
LoadIssues(opts);
|
|
|
|
|
ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s.ApplicationName;
|
|
|
|
|
ApplicationUrl = s?.ApplicationUrl.HasValue() ?? false ? s.ApplicationUrl : string.Empty;
|
|
|
|
|
AvailableDate = req?.MarkedAsAvailable?.ToString("D") ?? string.Empty;
|
|
|
|
|
DenyReason = req?.DeniedReason;
|
|
|
|
|
RequestId = req?.Id.ToString();
|
|
|
|
|
ProviderId = req?.ParentRequest?.ExternalProviderId.ToString() ?? string.Empty;
|
|
|
|
|
string title;
|
|
|
|
|
if (req == null)
|
|
|
|
|
{
|
|
|
|
|
opts.Substitutes.TryGetValue("Title", out title);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
RequestedUser = req?.RequestedUser?.UserName;
|
|
|
|
|
RequestedDate = req?.RequestedDate.ToString("D");
|
|
|
|
|
|
|
|
|
|
if (Type.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
title = req?.ParentRequest.Title;
|
|
|
|
|
Type = HumanizeReturnType(req?.RequestType);
|
|
|
|
|
}
|
|
|
|
|
DenyReason = req?.DeniedReason;
|
|
|
|
|
ApplicationUrl = (s?.ApplicationUrl.HasValue() ?? false) ? s.ApplicationUrl : string.Empty;
|
|
|
|
|
ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s?.ApplicationName;
|
|
|
|
|
RequestedUser = req?.RequestedUser?.UserName;
|
|
|
|
|
|
|
|
|
|
if (UserName.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
// Can be set if it's an issue
|
|
|
|
|
UserName = req?.RequestedUser?.UserName;
|
|
|
|
|
}
|
|
|
|
|
AvailableDate = req?.MarkedAsAvailable?.ToString("D") ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
if (Alias.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
Alias = (req?.RequestedUser?.Alias.HasValue() ?? false) ? req?.RequestedUser?.Alias : req?.RequestedUser?.UserName;
|
|
|
|
|
Alias = req?.RequestedUser?.Alias.HasValue() ?? false
|
|
|
|
|
? req.RequestedUser?.Alias
|
|
|
|
|
: req?.RequestedUser?.UserName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pref != null)
|
|
|
|
|
{
|
|
|
|
|
UserPreference = pref.Value.HasValue() ? pref.Value : Alias;
|
|
|
|
|
}
|
|
|
|
|
Title = title;
|
|
|
|
|
RequestedDate = req?.RequestedDate.ToString("D");
|
|
|
|
|
if (Type.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
Type = req?.RequestType.Humanize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Overview = req?.ParentRequest.Overview;
|
|
|
|
|
Year = req?.ParentRequest.ReleaseDate.Year.ToString();
|
|
|
|
|
|
|
|
|
|
PosterImage = string.Format((req?.ParentRequest.PosterPath ?? string.Empty).StartsWith("/", StringComparison.InvariantCultureIgnoreCase)
|
|
|
|
|
? "https://image.tmdb.org/t/p/w300{0}" : "https://image.tmdb.org/t/p/w300/{0}", req?.ParentRequest.PosterPath);
|
|
|
|
|
|
|
|
|
|
AdditionalInformation = opts.AdditionalInformation;
|
|
|
|
|
// DO Episode and Season Lists
|
|
|
|
|
|
|
|
|
|
var episodes = req?.SeasonRequests?.SelectMany(x => x.Episodes) ?? new List<EpisodeRequests>();
|
|
|
|
|
var seasons = req?.SeasonRequests?.OrderBy(x => x.SeasonNumber).ToList() ?? new List<SeasonRequests>();
|
|
|
|
|
var orderedEpisodes = episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
|
|
|
|
var epSb = new StringBuilder();
|
|
|
|
|
var seasonSb = new StringBuilder();
|
|
|
|
|
for (var i = 0; i < orderedEpisodes.Count; i++)
|
|
|
|
|
private static string HumanizeReturnType(RequestType? requestType)
|
|
|
|
|
{
|
|
|
|
|
var ep = orderedEpisodes[i];
|
|
|
|
|
if (i < orderedEpisodes.Count - 1)
|
|
|
|
|
return requestType switch
|
|
|
|
|
{
|
|
|
|
|
epSb.Append($"{ep.EpisodeNumber},");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
epSb.Append($"{ep.EpisodeNumber}");
|
|
|
|
|
}
|
|
|
|
|
null => string.Empty,
|
|
|
|
|
RequestType.TvShow => "TV Show",
|
|
|
|
|
_ => requestType.Humanize()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < seasons.Count; i++)
|
|
|
|
|
private void LoadTitle(NotificationOptions opts, BaseRequest req)
|
|
|
|
|
{
|
|
|
|
|
var ep = seasons[i];
|
|
|
|
|
if (i < seasons.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
seasonSb.Append($"{ep.SeasonNumber},");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
seasonSb.Append($"{ep.SeasonNumber}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EpisodesList = epSb.ToString();
|
|
|
|
|
SeasonsList = seasonSb.ToString();
|
|
|
|
|
CalculateRequestStatus(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Setup(OmbiUser user, CustomizationSettings s)
|
|
|
|
|
switch (req)
|
|
|
|
|
{
|
|
|
|
|
ApplicationUrl = (s?.ApplicationUrl.HasValue() ?? false) ? s.ApplicationUrl : string.Empty;
|
|
|
|
|
ApplicationName = string.IsNullOrEmpty(s?.ApplicationName) ? "Ombi" : s?.ApplicationName;
|
|
|
|
|
RequestedUser = user.UserName;
|
|
|
|
|
Alias = user.UserAlias;
|
|
|
|
|
UserName = user.UserName;
|
|
|
|
|
case null:
|
|
|
|
|
opts.Substitutes.TryGetValue("Title", out string title);
|
|
|
|
|
Title = title;
|
|
|
|
|
break;
|
|
|
|
|
case ChildRequests tvShowRequest:
|
|
|
|
|
Title = tvShowRequest.ParentRequest?.Title;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Title = req.Title;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadIssues(NotificationOptions opts)
|
|
|
|
|
{
|
|
|
|
|
var val = string.Empty;
|
|
|
|
|
IssueDescription = opts.Substitutes.TryGetValue("IssueDescription", out val) ? val : string.Empty;
|
|
|
|
|
IssueCategory = opts.Substitutes.TryGetValue("IssueCategory", out val) ? val : string.Empty;
|
|
|
|
|
IssueStatus = opts.Substitutes.TryGetValue("IssueStatus", out val) ? val : string.Empty;
|
|
|
|
|
IssueSubject = opts.Substitutes.TryGetValue("IssueSubject", out val) ? val : string.Empty;
|
|
|
|
|
NewIssueComment = opts.Substitutes.TryGetValue("NewIssueComment", out val) ? val : string.Empty;
|
|
|
|
|
UserName = opts.Substitutes.TryGetValue("IssueUser", out val) ? val : string.Empty;
|
|
|
|
|
Alias = opts.Substitutes.TryGetValue("IssueUserAlias", out val) ? val : string.Empty;
|
|
|
|
|
Type = opts.Substitutes.TryGetValue("RequestType", out val) ? val.Humanize() : string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CalculateRequestStatus(BaseRequest req)
|
|
|
|
@ -238,16 +176,19 @@ namespace Ombi.Notifications
|
|
|
|
|
RequestStatus = "Available";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (req.Denied ?? false)
|
|
|
|
|
{
|
|
|
|
|
RequestStatus = "Denied";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!req.Available && req.Approved)
|
|
|
|
|
{
|
|
|
|
|
RequestStatus = "Processing Request";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RequestStatus = "Pending Approval";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|