@ -1,10 +1,13 @@
using System ;
using System ;
using System.Collections.Generic ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using Ombi.Helpers ;
using Ombi.Helpers ;
using Ombi.Notifications.Models ;
using Ombi.Notifications.Models ;
using Ombi.Settings.Settings.Models ;
using Ombi.Settings.Settings.Models ;
using Ombi.Store.Entities ;
using Ombi.Store.Entities ;
using Ombi.Store.Entities.Requests ;
using Ombi.Store.Entities.Requests ;
using Ombi.Store.Repository.Requests ;
namespace Ombi.Notifications
namespace Ombi.Notifications
{
{
@ -25,9 +28,9 @@ namespace Ombi.Notifications
}
}
ApplicationUrl = ( s ? . ApplicationUrl . HasValue ( ) ? ? false ) ? s . ApplicationUrl : string . Empty ;
ApplicationUrl = ( s ? . ApplicationUrl . HasValue ( ) ? ? false ) ? s . ApplicationUrl : string . Empty ;
ApplicationName = string . IsNullOrEmpty ( s ? . ApplicationName ) ? "Ombi" : s ? . ApplicationName ;
ApplicationName = string . IsNullOrEmpty ( s ? . ApplicationName ) ? "Ombi" : s ? . ApplicationName ;
RequestedUser = string . IsNullOrEmpty ( req ? . RequestedUser ? . Alias)
RequestedUser = req ? . RequestedUser ? . UserName;
? req ? . RequestedUser ? . UserName
UserName = req ? . RequestedUser ? . UserName ;
: req ? . RequestedUser ? . Alias ;
Alias = ( req ? . RequestedUser ? . Alias . HasValue ( ) ? ? false ) ? req ? . RequestedUser ? . Alias : req ? . RequestedUser ? . UserName ;
Title = title ;
Title = title ;
RequestedDate = req ? . RequestedDate . ToString ( "D" ) ;
RequestedDate = req ? . RequestedDate . ToString ( "D" ) ;
Type = req ? . RequestType . ToString ( ) ;
Type = req ? . RequestType . ToString ( ) ;
@ -43,6 +46,8 @@ namespace Ombi.Notifications
ApplicationUrl = ( s ? . ApplicationUrl . HasValue ( ) ? ? false ) ? s . ApplicationUrl : string . Empty ;
ApplicationUrl = ( s ? . ApplicationUrl . HasValue ( ) ? ? false ) ? s . ApplicationUrl : string . Empty ;
ApplicationName = string . IsNullOrEmpty ( s ? . ApplicationName ) ? "Ombi" : s ? . ApplicationName ;
ApplicationName = string . IsNullOrEmpty ( s ? . ApplicationName ) ? "Ombi" : s ? . ApplicationName ;
RequestedUser = username . UserName ;
RequestedUser = username . UserName ;
UserName = username . UserName ;
Alias = username . Alias . HasValue ( ) ? username . Alias : username . UserName ;
}
}
public void Setup ( NotificationOptions opts , ChildRequests req , CustomizationSettings s )
public void Setup ( NotificationOptions opts , ChildRequests req , CustomizationSettings s )
@ -59,9 +64,9 @@ namespace Ombi.Notifications
}
}
ApplicationUrl = ( s ? . ApplicationUrl . HasValue ( ) ? ? false ) ? s . ApplicationUrl : string . Empty ;
ApplicationUrl = ( s ? . ApplicationUrl . HasValue ( ) ? ? false ) ? s . ApplicationUrl : string . Empty ;
ApplicationName = string . IsNullOrEmpty ( s ? . ApplicationName ) ? "Ombi" : s ? . ApplicationName ;
ApplicationName = string . IsNullOrEmpty ( s ? . ApplicationName ) ? "Ombi" : s ? . ApplicationName ;
RequestedUser = string . IsNullOrEmpty ( req ? . RequestedUser .Alias )
RequestedUser = req ? . RequestedUser ?. UserName ;
? req ? . RequestedUser .UserName
UserName = req ? . RequestedUser ? .UserName ;
: req ? . RequestedUser .Alias ;
Alias = ( req ? . RequestedUser ? . Alias . HasValue ( ) ? ? false ) ? req ? . RequestedUser ? .Alias : req ? . RequestedUser ? . UserName ;
Title = title ;
Title = title ;
RequestedDate = req ? . RequestedDate . ToString ( "D" ) ;
RequestedDate = req ? . RequestedDate . ToString ( "D" ) ;
Type = req ? . RequestType . ToString ( ) ;
Type = req ? . RequestType . ToString ( ) ;
@ -71,6 +76,40 @@ namespace Ombi.Notifications
$"https://image.tmdb.org/t/p/w300{req?.ParentRequest.PosterPath}" : req ? . ParentRequest . PosterPath ;
$"https://image.tmdb.org/t/p/w300{req?.ParentRequest.PosterPath}" : req ? . ParentRequest . PosterPath ;
AdditionalInformation = opts . AdditionalInformation ;
AdditionalInformation = opts . AdditionalInformation ;
// DO Episode and Season Lists
// 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 + + )
{
var ep = orderedEpisodes [ i ] ;
if ( i < orderedEpisodes . Count - 1 )
{
epSb . Append ( $"{ep.EpisodeNumber}," ) ;
}
else
{
epSb . Append ( $"{ep.EpisodeNumber}" ) ;
}
}
for ( var i = 0 ; i < seasons . Count ; i + + )
{
var ep = seasons [ i ] ;
if ( i < seasons . Count - 1 )
{
seasonSb . Append ( $"{ep.SeasonNumber}," ) ;
}
else
{
seasonSb . Append ( $"{ep.SeasonNumber}" ) ;
}
}
EpisodesList = epSb . ToString ( ) ;
SeasonsList = seasonSb . ToString ( ) ;
}
}
public void Setup ( OmbiUser user , CustomizationSettings s )
public void Setup ( OmbiUser user , CustomizationSettings s )
@ -88,13 +127,14 @@ namespace Ombi.Notifications
IssueStatus = opts . Substitutes . TryGetValue ( "IssueStatus" , 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 ;
IssueSubject = opts . Substitutes . TryGetValue ( "IssueSubject" , out val ) ? val : string . Empty ;
NewIssueComment = opts . Substitutes . TryGetValue ( "NewIssueComment" , out val ) ? val : string . Empty ;
NewIssueComment = opts . Substitutes . TryGetValue ( "NewIssueComment" , out val ) ? val : string . Empty ;
Requested User = opts . Substitutes . TryGetValue ( "IssueUser" , out val ) ? val : string . Empty ;
UserName = opts . Substitutes . TryGetValue ( "IssueUser" , out val ) ? val : string . Empty ;
}
}
// User Defined
// User Defined
public string RequestedUser { get ; set ; }
public string RequestedUser { get ; set ; }
public string UserName = > RequestedUser ;
public string UserName { get ; set ; }
public string IssueUser = > RequestedUser ;
public string IssueUser = > UserName ;
public string Alias { get ; set ; }
public string Title { get ; set ; }
public string Title { get ; set ; }
public string RequestedDate { get ; set ; }
public string RequestedDate { get ; set ; }
@ -144,6 +184,7 @@ namespace Ombi.Notifications
{ nameof ( NewIssueComment ) , NewIssueComment } ,
{ nameof ( NewIssueComment ) , NewIssueComment } ,
{ nameof ( IssueUser ) , IssueUser } ,
{ nameof ( IssueUser ) , IssueUser } ,
{ nameof ( UserName ) , UserName } ,
{ nameof ( UserName ) , UserName } ,
{ nameof ( Alias ) , Alias } ,
} ;
} ;
}
}
}
}