@ -19,7 +19,7 @@ namespace Ombi.Notifications.Interfaces
public abstract class BaseNotification < T > : INotification where T : Settings . Settings . Models . Settings , new ( )
{
protected BaseNotification ( ISettingsService < T > settings , INotificationTemplatesRepository templateRepo , IMovieRequestRepository movie , ITvRequestRepository tv ,
ISettingsService < CustomizationSettings > customization , ILogger < BaseNotification < T > > log , IRepository < RequestSubscription > sub )
ISettingsService < CustomizationSettings > customization , ILogger < BaseNotification < T > > log , IRepository < RequestSubscription > sub , IMusicRequestRepository album )
{
Settings = settings ;
TemplateRepository = templateRepo ;
@ -30,12 +30,14 @@ namespace Ombi.Notifications.Interfaces
CustomizationSettings . ClearCache ( ) ;
RequestSubscription = sub ;
_log = log ;
AlbumRepository = album ;
}
protected ISettingsService < T > Settings { get ; }
protected INotificationTemplatesRepository TemplateRepository { get ; }
protected IMovieRequestRepository MovieRepository { get ; }
protected ITvRequestRepository TvRepository { get ; }
protected IMusicRequestRepository AlbumRepository { get ; }
protected CustomizationSettings Customization { get ; set ; }
protected IRepository < RequestSubscription > RequestSubscription { get ; set ; }
private ISettingsService < CustomizationSettings > CustomizationSettings { get ; }
@ -43,6 +45,7 @@ namespace Ombi.Notifications.Interfaces
protected ChildRequests TvRequest { get ; set ; }
protected AlbumRequest AlbumRequest { get ; set ; }
protected MovieRequests MovieRequest { get ; set ; }
protected IQueryable < OmbiUser > SubsribedUsers { get ; private set ; }
@ -130,10 +133,14 @@ namespace Ombi.Notifications.Interfaces
{
MovieRequest = await MovieRepository . GetWithUser ( ) . FirstOrDefaultAsync ( x = > x . Id = = requestId ) ;
}
else
else if ( type = = RequestType . TvShow )
{
TvRequest = await TvRepository . GetChild ( ) . FirstOrDefaultAsync ( x = > x . Id = = requestId ) ;
}
else if ( type = = RequestType . Album )
{
AlbumRequest = await AlbumRepository . GetWithUser ( ) . FirstOrDefaultAsync ( x = > x . Id = = requestId ) ;
}
}
private async Task < T > GetConfiguration ( )
@ -181,11 +188,16 @@ namespace Ombi.Notifications.Interfaces
curlys . Setup ( model , MovieRequest , Customization ) ;
}
else
else if ( model . RequestType = = RequestType . TvShow )
{
_log . LogDebug ( "Notification options: {@model}, Req: {@TvRequest}, Settings: {@Customization}" , model , TvRequest , Customization ) ;
curlys . Setup ( model , TvRequest , Customization ) ;
}
else if ( model . RequestType = = RequestType . Album )
{
_log . LogDebug ( "Notification options: {@model}, Req: {@AlbumRequest}, Settings: {@Customization}" , model , AlbumRequest , Customization ) ;
curlys . Setup ( model , AlbumRequest , Customization ) ;
}
var parsed = resolver . ParseMessage ( template , curlys ) ;
return parsed ;