Esempio n. 1
0
        public ApprovalModule(IRequestService service, ISonarrApi sonarrApi,
                              ISettingsService <SonarrSettings> sonarrSettings, ISickRageApi srApi, ISettingsService <SickRageSettings> srSettings,
                              ISettingsService <HeadphonesSettings> hpSettings, IHeadphonesApi hpApi, ISettingsService <PlexRequestSettings> pr, ITransientFaultQueue faultQueue
                              , ISecurityExtensions security, IMovieSender movieSender, ICacheProvider cache) : base("approval", pr, security)
        {
            Before += (ctx) => Security.AdminLoginRedirect(ctx, Permissions.Administrator, Permissions.ManageRequests);

            Service            = service;
            SonarrApi          = sonarrApi;
            SonarrSettings     = sonarrSettings;
            SickRageApi        = srApi;
            SickRageSettings   = srSettings;
            HeadphonesSettings = hpSettings;
            HeadphoneApi       = hpApi;
            FaultQueue         = faultQueue;
            MovieSender        = movieSender;
            Cache = cache;

            Post["/approve", true] = async(x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId);

            Post["/deny", true] = async(x, ct) => await DenyRequest((int)Request.Form.requestid, (string)Request.Form.reason);

            Post["/approveall", true] = async(x, ct) => await ApproveAll();

            Post["/approveallmovies", true] = async(x, ct) => await ApproveAllMovies();

            Post["/approvealltvshows", true] = async(x, ct) => await ApproveAllTVShows();

            Post["/deleteallmovies", true] = async(x, ct) => await DeleteAllMovies();

            Post["/deletealltvshows", true] = async(x, ct) => await DeleteAllTVShows();

            Post["/deleteallalbums", true] = async(x, ct) => await DeleteAllAlbums();
        }
Esempio n. 2
0
        protected BaseModule(string modulePath, ISettingsService <PlexRequestSettings> settingsService, ISecurityExtensions security)
        {
            var settings = settingsService.GetSettings();
            var baseUrl  = settings.BaseUrl;

            BaseUrl = baseUrl;

            var settingModulePath = string.IsNullOrEmpty(baseUrl) ? modulePath : $"{baseUrl}/{modulePath}";

            ModulePath = settingModulePath;
            Security   = security;

            Before += (ctx) =>
            {
                SetCookie();

                if (!string.IsNullOrEmpty(ctx.Request.Session["TempMessage"] as string))
                {
                    ctx.ViewBag.TempMessage = ctx.Request.Session["TempMessage"];
                    ctx.ViewBag.TempType    = ctx.Request.Session["TempType"];
                    ctx.Request.Session.DeleteAll();
                }
                return(null);
            };
        }
Esempio n. 3
0
        public UserManagementModule(ISettingsService <PlexRequestSettings> pr, ICustomUserMapper m, IPlexApi plexApi, ISettingsService <PlexSettings> plex, IRepository <UserLogins> userLogins, IPlexUserRepository plexRepo
                                    , ISecurityExtensions security, IRequestService req, IAnalytics ana) : base("usermanagement", pr, security)
        {
#if !DEBUG
            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
#endif
            UserMapper          = m;
            PlexApi             = plexApi;
            PlexSettings        = plex;
            UserLoginsRepo      = userLogins;
            PlexUsersRepository = plexRepo;
            PlexRequestSettings = pr;
            RequestService      = req;
            Analytics           = ana;

            Get["/"] = x => Load();

            Get["/users", true] = async(x, ct) => await LoadUsers();

            Post["/createuser", true] = async(x, ct) => await CreateUser();

            Get["/local/{id}"]      = x => LocalDetails((Guid)x.id);
            Get["/plex/{id}", true] = async(x, ct) => await PlexDetails(x.id);

            Get["/permissions"]       = x => GetEnum <Permissions>();
            Get["/features"]          = x => GetEnum <Features>();
            Post["/updateuser", true] = async(x, ct) => await UpdateUser();

            Post["/deleteuser"] = x => DeleteUser();
        }
Esempio n. 4
0
        public ScheduledJobsRunnerModule(ISettingsService <PlexRequestSettings> settingsService,
                                         ISecurityExtensions security, IPlexContentCacher contentCacher, ISonarrCacher sonarrCacher, IWatcherCacher watcherCacher,
                                         IRadarrCacher radarrCacher, ICouchPotatoCacher cpCacher, IStoreBackup store, ISickRageCacher srCacher, IAvailabilityChecker plexChceker,
                                         IStoreCleanup cleanup, IUserRequestLimitResetter requestLimit, IPlexEpisodeCacher episodeCacher, IRecentlyAdded recentlyAdded,
                                         IFaultQueueHandler faultQueueHandler, IPlexUserChecker plexUserChecker) : base("admin", settingsService, security)
        {
            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            PlexContentCacher   = contentCacher;
            SonarrCacher        = sonarrCacher;
            RadarrCacher        = radarrCacher;
            WatcherCacher       = watcherCacher;
            CpCacher            = cpCacher;
            StoreBackup         = store;
            SrCacher            = srCacher;
            AvailabilityChecker = plexChceker;
            StoreCleanup        = cleanup;
            RequestLimit        = requestLimit;
            EpisodeCacher       = episodeCacher;
            RecentlyAdded       = recentlyAdded;
            FaultQueueHandler   = faultQueueHandler;
            PlexUserChecker     = plexUserChecker;

            Post["/schedulerun", true] = async(x, ct) => await ScheduleRun((string)Request.Form.key);
        }
Esempio n. 5
0
        public IntegrationModule(ISettingsService <PlexRequestSettings> settingsService, ISettingsService <WatcherSettings> watcher,
                                 ISettingsService <CouchPotatoSettings> cp, ISecurityExtensions security, IAnalytics a, ISettingsService <RadarrSettings> radarrSettings,
                                 ICacheProvider cache, IRadarrApi radarrApi, ISonarrApi sonarrApi) : base("admin", settingsService, security)
        {
            WatcherSettings = watcher;
            Analytics       = a;
            CpSettings      = cp;
            Cache           = cache;
            RadarrApi       = radarrApi;
            RadarrSettings  = radarrSettings;
            SonarrApi       = sonarrApi;

            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);


            Post["/sonarrrootfolders"] = _ => GetSonarrRootFolders();

            Get["/watcher", true] = async(x, ct) => await Watcher();

            Post["/watcher", true] = async(x, ct) => await SaveWatcher();

            Get["/radarr", true] = async(x, ct) => await Radarr();

            Post["/radarr", true] = async(x, ct) => await SaveRadarr();


            Post["/radarrprofiles"] = _ => GetRadarrQualityProfiles();
        }
Esempio n. 6
0
        public RequestsModule(
            IRequestService service,
            ISettingsService <PlexRequestSettings> prSettings,
            ISettingsService <PlexSettings> plex,
            INotificationService notify,
            ISettingsService <SonarrSettings> sonarrSettings,
            ISettingsService <SickRageSettings> sickRageSettings,
            ISettingsService <CouchPotatoSettings> cpSettings,
            ICouchPotatoApi cpApi,
            ISonarrApi sonarrApi,
            ISickRageApi sickRageApi,
            ICacheProvider cache,
            IAnalytics an,
            INotificationEngine engine,
            ISecurityExtensions security,
            ISettingsService <CustomizationSettings> customSettings) : base("requests", prSettings, security)
        {
            Service             = service;
            PrSettings          = prSettings;
            PlexSettings        = plex;
            NotificationService = notify;
            SonarrSettings      = sonarrSettings;
            SickRageSettings    = sickRageSettings;
            CpSettings          = cpSettings;
            SonarrApi           = sonarrApi;
            SickRageApi         = sickRageApi;
            CpApi                 = cpApi;
            Cache                 = cache;
            Analytics             = an;
            NotificationEngine    = engine;
            CustomizationSettings = customSettings;

            Get["/", true] = async(x, ct) => await LoadRequests();

            Get["/movies", true] = async(x, ct) => await GetMovies();

            Get["/tvshows", true] = async(c, ct) => await GetTvShows();

            Get["/albums", true] = async(x, ct) => await GetAlbumRequests();

            Post["/delete", true] = async(x, ct) => await DeleteRequest((int)Request.Form.id);

            Post["/reportissue", true] = async(x, ct) => await ReportIssue((int)Request.Form.requestId, (IssueState)(int)Request.Form.issue, null);

            Post["/reportissuecomment", true] = async(x, ct) => await ReportIssue((int)Request.Form.requestId, IssueState.Other, (string)Request.Form.commentArea);

            Post["/clearissues", true] = async(x, ct) => await ClearIssue((int)Request.Form.Id);

            Post["/changeavailability", true] = async(x, ct) => await ChangeRequestAvailability((int)Request.Form.Id, (bool)Request.Form.Available);

            Post["/changeRootFolder", true] = async(x, ct) => await ChangeRootFolder((int)Request.Form.requestId, (int)Request.Form.rootFolderId);

            Get["/UpdateFilters", true] = async(x, ct) => await GetFilterAndSortSettings();
        }
Esempio n. 7
0
        public CustomizationModule(ISettingsService <PlexRequestSettings> settingsService,
                                   ISettingsService <CustomizationSettings> cust, ISecurityExtensions security)
            : base("admin", settingsService, security)
        {
            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            Settings = cust;

            Get["/customization", true] = async(x, ct) => await Index();

            Post["/customization", true] = async(x, ct) => await Save();
        }
Esempio n. 8
0
        public IntegrationModule(ISettingsService <PlexRequestSettings> settingsService, ISettingsService <WatcherSettings> watcher,
                                 ISettingsService <CouchPotatoSettings> cp, ISecurityExtensions security, IAnalytics a) : base("admin", settingsService, security)
        {
            WatcherSettings = watcher;
            Analytics       = a;
            CpSettings      = cp;

            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            Get["/watcher", true] = async(x, ct) => await Watcher();

            Post["/watcher", true] = async(x, ct) => await SaveWatcher();
        }
Esempio n. 9
0
        protected BaseModule(ISettingsService <PlexRequestSettings> settingsService, ISecurityExtensions security)
        {
            var settings = settingsService.GetSettings();
            var baseUrl  = settings.BaseUrl;

            BaseUrl = baseUrl;

            var modulePath = string.IsNullOrEmpty(baseUrl) ? string.Empty : baseUrl;

            ModulePath = modulePath;
            Security   = security;

            Before += (ctx) => SetCookie();
        }
Esempio n. 10
0
        public SystemStatusModule(ISettingsService <PlexRequestSettings> settingsService, ICacheProvider cache, ISettingsService <SystemSettings> ss,
                                  ISecurityExtensions security, IAnalytics a, IAppveyorApi appveyor) : base("admin", settingsService, security)
        {
            Cache          = cache;
            SystemSettings = ss;
            Analytics      = a;
            AppveyorApi    = appveyor;

            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            Get["/status", true] = async(x, ct) => await Status();

            Post["/save", true] = async(x, ct) => await Save();

            Post["/autoupdate"]   = x => AutoUpdate();
            Get["/changes", true] = async(x, ct) => await GetLatestChanges();
        }
Esempio n. 11
0
        public AboutModule(ISettingsService <PlexRequestSettings> settingsService,
                           ISettingsService <SystemSettings> systemService, ISecurityExtensions security,
                           IStatusChecker statusChecker, IResourceLinker linker, ISqliteConfiguration config) : base("admin", settingsService, security)
        {
            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            SettingsService = systemService;
            StatusChecker   = statusChecker;
            Linker          = linker;
            SqlConfig       = config;

            Get["AboutPage", "/about", true] = async(x, ct) => await Index();

            Post["/about", true] = async(x, ct) => await ReportIssue();

            Get["/OAuth", true] = async(x, ct) => await OAuth();

            Get["/authorize", true] = async(x, ct) => await Authorize();
        }
Esempio n. 12
0
        public UserWizardModule(ISettingsService <PlexRequestSettings> pr, ISettingsService <PlexSettings> plex,
                                IPlexApi plexApi,
                                ISettingsService <AuthenticationSettings> auth, ICustomUserMapper m, IAnalytics a,
                                ISecurityExtensions security, IEmbyApi embyApi,
                                ISettingsService <EmbySettings> embySettings) : base("wizard", pr, security)
        {
            PlexSettings        = plex;
            PlexApi             = plexApi;
            PlexRequestSettings = pr;
            Auth         = auth;
            Mapper       = m;
            Analytics    = a;
            EmbySettings = embySettings;
            EmbyApi      = embyApi;

            Get["/", true] = async(x, ct) =>
            {
                a.TrackEventAsync(Category.Wizard, Action.Start, "Started the wizard", Username,
                                  CookieHelper.GetAnalyticClientId(Cookies));

                var settings = await PlexRequestSettings.GetSettingsAsync();

                if (settings.Wizard)
                {
                    return(Context.GetRedirect("~/search"));
                }
                return(View["Index"]);
            };
            Post["/plexAuth"]   = x => PlexAuth();
            Post["/plex", true] = async(x, ct) => await Plex();

            Post["/plexrequest", true] = async(x, ct) => await PlexRequest();

            Post["/auth", true] = async(x, ct) => await Authentication();

            Post["/createuser", true] = async(x, ct) => await CreateUser();


            Post["/embyauth", true] = async(x, ct) => await EmbyAuth();
        }
Esempio n. 13
0
        public FaultQueueModule(ISettingsService <PlexRequestSettings> settingsService, IRepository <RequestQueue> requestQueue, ISecurityExtensions security) : base("admin", settingsService, security)
        {
            RequestQueue = requestQueue;

            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            Get["Index", "/faultqueue"] = x => Index();
        }
Esempio n. 14
0
 protected BaseApiModule(string modulePath, ISettingsService <PlexRequestSettings> s, ISecurityExtensions security) : base(modulePath, s, security)
 {
     Settings = s;
     Before  += (ctx) => CheckAuth();
 }
Esempio n. 15
0
        public FaultQueueModule(ISettingsService <PlexRequestSettings> settingsService, IRepository <RequestQueue> requestQueue, ISecurityExtensions security) : base("admin", settingsService, security)
        {
            RequestQueue = requestQueue;

            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            Get["Index", "/faultqueue"] = x => Index();
            Get["DeleteFault", "/deleteFault", true] = async(x, ct) => await DeleteFault(Convert.ToInt32(Request.Form.id));
        }
Esempio n. 16
0
 public ApiDocsModule(ISettingsService <PlexRequestSettings> pr, ISecurityExtensions security) : base("apidocs", pr, security)
 {
     Get["/"] = x => Documentation();
 }
Esempio n. 17
0
        public AdminModule(ISettingsService <PlexRequestSettings> prService,
                           ISettingsService <CouchPotatoSettings> cpService,
                           ISettingsService <AuthenticationSettings> auth,
                           ISettingsService <PlexSettings> plex,
                           ISettingsService <SonarrSettings> sonarr,
                           ISettingsService <SickRageSettings> sickrage,
                           ISonarrApi sonarrApi,
                           ISettingsService <EmailNotificationSettings> email,
                           IPlexApi plexApi,
                           ISettingsService <PushbulletNotificationSettings> pbSettings,
                           PushbulletApi pbApi,
                           ICouchPotatoApi cpApi,
                           ISettingsService <PushoverNotificationSettings> pushoverSettings,
                           ISettingsService <NewletterSettings> newsletter,
                           IPushoverApi pushoverApi,
                           IRepository <LogEntity> logsRepo,
                           INotificationService notify,
                           ISettingsService <HeadphonesSettings> headphones,
                           ISettingsService <LogSettings> logs,
                           ICacheProvider cache, ISettingsService <SlackNotificationSettings> slackSettings,
                           ISlackApi slackApi, ISettingsService <LandingPageSettings> lp,
                           ISettingsService <ScheduledJobsSettings> scheduler, IJobRecord rec, IAnalytics analytics,
                           ISettingsService <NotificationSettingsV2> notifyService, IRecentlyAdded recentlyAdded,
                           ISettingsService <WatcherSettings> watcherSettings
                           , ISecurityExtensions security) : base("admin", prService, security)
        {
            PrService            = prService;
            CpService            = cpService;
            AuthService          = auth;
            PlexService          = plex;
            SonarrService        = sonarr;
            SonarrApi            = sonarrApi;
            EmailService         = email;
            PlexApi              = plexApi;
            PushbulletService    = pbSettings;
            PushbulletApi        = pbApi;
            CpApi                = cpApi;
            SickRageService      = sickrage;
            LogsRepo             = logsRepo;
            PushoverService      = pushoverSettings;
            PushoverApi          = pushoverApi;
            NotificationService  = notify;
            HeadphonesService    = headphones;
            NewsLetterService    = newsletter;
            LogService           = logs;
            Cache                = cache;
            SlackSettings        = slackSettings;
            SlackApi             = slackApi;
            LandingSettings      = lp;
            ScheduledJobSettings = scheduler;
            JobRecorder          = rec;
            Analytics            = analytics;
            NotifySettings       = notifyService;
            RecentlyAdded        = recentlyAdded;
            WatcherSettings      = watcherSettings;

            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            Get["/"] = _ => Admin();

            Get["/authentication", true] = async(x, ct) => await Authentication();

            Post["/authentication", true] = async(x, ct) => await SaveAuthentication();

            Post["/", true] = async(x, ct) => await SaveAdmin();

            Post["/requestauth"] = _ => RequestAuthToken();

            Get["/getusers"] = _ => GetUsers();

            Get["/couchpotato"]  = _ => CouchPotato();
            Post["/couchpotato"] = _ => SaveCouchPotato();

            Get["/plex"]        = _ => Plex();
            Post["/plex", true] = async(x, ct) => await SavePlex();

            Get["/sonarr"]  = _ => Sonarr();
            Post["/sonarr"] = _ => SaveSonarr();

            Get["/sickrage"]  = _ => Sickrage();
            Post["/sickrage"] = _ => SaveSickrage();

            Post["/sonarrprofiles"]   = _ => GetSonarrQualityProfiles();
            Post["/cpprofiles", true] = async(x, ct) => await GetCpProfiles();

            Post["/cpapikey"] = x => GetCpApiKey();

            Get["/emailnotification"]            = _ => EmailNotifications();
            Post["/emailnotification"]           = _ => SaveEmailNotifications();
            Post["/testemailnotification", true] = async(x, ct) => await TestEmailNotifications();

            Get["/pushbulletnotification"]            = _ => PushbulletNotifications();
            Post["/pushbulletnotification"]           = _ => SavePushbulletNotifications();
            Post["/testpushbulletnotification", true] = async(x, ct) => await TestPushbulletNotifications();

            Get["/pushovernotification"]            = _ => PushoverNotifications();
            Post["/pushovernotification"]           = _ => SavePushoverNotifications();
            Post["/testpushovernotification", true] = async(x, ct) => await TestPushoverNotifications();

            Get["/logs"]      = _ => Logs();
            Get["/loglevel"]  = _ => GetLogLevels();
            Post["/loglevel"] = _ => UpdateLogLevels(Request.Form.level);
            Get["/loadlogs"]  = _ => LoadLogs();

            Get["/headphones"]  = _ => Headphones();
            Post["/headphones"] = _ => SaveHeadphones();

            Get["/newsletter"]  = _ => Newsletter();
            Post["/newsletter"] = _ => SaveNewsletter();

            Post["/createapikey"] = x => CreateApiKey();



            Post["/testslacknotification", true] = async(x, ct) => await TestSlackNotification();

            Get["/slacknotification"]  = _ => SlackNotifications();
            Post["/slacknotification"] = _ => SaveSlackNotifications();

            Get["/landingpage", true] = async(x, ct) => await LandingPage();

            Post["/landingpage", true] = async(x, ct) => await SaveLandingPage();

            Get["/scheduledjobs", true] = async(x, ct) => await GetScheduledJobs();

            Post["/scheduledjobs", true] = async(x, ct) => await SaveScheduledJobs();

            Post["/clearlogs", true] = async(x, ct) => await ClearLogs();

            Get["/notificationsettings", true] = async(x, ct) => await NotificationSettings();

            Post["/notificationsettings"] = x => SaveNotificationSettings();

            Post["/recentlyAddedTest"] = x => RecentlyAddedTest();
        }
Esempio n. 18
0
        public UserManagementSettingsModule(ISettingsService <PlexRequestSettings> settingsService, ISettingsService <UserManagementSettings> umSettings, ISecurityExtensions security) : base("admin", settingsService, security)
        {
            UserManagementSettings = umSettings;

            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

            Get["UserManagementSettings", "/usermanagementsettings", true] = async(x, ct) => await Index();

            Post["/usermanagementsettings", true] = async(x, ct) => await Update();
        }
Esempio n. 19
0
        public LoginModule(ISettingsService <PlexRequestSettings> pr, ICustomUserMapper m, IResourceLinker linker, IRepository <UserLogins> userLoginRepo, ISecurityExtensions security)
            : base(pr, security)
        {
            UserMapper = m;
            Get["LocalLogin", "/login"] = _ =>
            {
                if (LoggedIn)
                {
                    var url = linker.BuildRelativeUri(Context, "SearchIndex");
                    return(Response.AsRedirect(url.ToString()));
                }
                dynamic model = new ExpandoObject();
                model.Redirect = Request.Query.redirect.Value ?? string.Empty;
                model.Errored  = Request.Query.error.HasValue;
                var adminCreated = UserMapper.DoUsersExist();
                model.AdminExists = adminCreated;
                return(View["Index", model]);
            };

            Get["/logout"] = x =>
            {
                if (Session[SessionKeys.UsernameKey] != null)
                {
                    Session.Delete(SessionKeys.UsernameKey);
                }
                return(CustomModuleExtensions.LogoutAndRedirect(this, !string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/" : "~/"));
            };

            Post["/login"] = x =>
            {
                var username = (string)Request.Form.Username;
                var password = (string)Request.Form.Password;
                var dtOffset = (int)Request.Form.DateTimeOffset;
                var redirect = (string)Request.Form.Redirect;

                var userId = UserMapper.ValidateUser(username, password);

                if (userId == null)
                {
                    return
                        (Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl)
                            ? $"~/{BaseUrl}/login?error=true&username="******"~/login?error=true&username="******"userlogin"))
                {
                    redirect = !string.IsNullOrEmpty(BaseUrl) ? $"/{BaseUrl}/search" : "/search";
                }

                userLoginRepo.Insert(new UserLogins
                {
                    LastLoggedIn = DateTime.UtcNow,
                    Type         = UserType.LocalUser,
                    UserId       = userId.ToString()
                });

                return(CustomModuleExtensions.LoginAndRedirect(this, userId.Value, expiry, redirect));
            };

            Get["/register"] = x =>
            {
                {
                    dynamic model = new ExpandoObject();
                    model.Errored = Request.Query.error.HasValue;

                    return(View["Register", model]);
                }
            };

            Post["/register"] = x =>
            {
                var username = (string)Request.Form.Username;
                var exists   = UserMapper.DoUsersExist();
                if (exists)
                {
                    return
                        (Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl)
                            ? $"~/{BaseUrl}/register?error=true"
                            : "~/register?error=true"));
                }
                var userId = UserMapper.CreateUser(username, Request.Form.Password, EnumHelper <Permissions> .All(), 0);
                Session[SessionKeys.UsernameKey] = username;
                return(CustomModuleExtensions.LoginAndRedirect(this, (Guid)userId));
            };

            Get["/changepassword"]  = _ => ChangePassword();
            Post["/changepassword"] = _ => ChangePasswordPost();
        }
Esempio n. 20
0
 protected BaseAuthModule(string modulePath, ISettingsService <PlexRequestSettings> pr, ISecurityExtensions security) : base(modulePath, pr, security)
 {
     PlexRequestSettings = pr;
     Before += (ctx) => CheckAuth();
 }
Esempio n. 21
0
        public ApiSettingsModule(ISettingsService <PlexRequestSettings> pr, ISettingsService <AuthenticationSettings> auth,
                                 ISettingsService <PlexSettings> plexSettings, ISettingsService <CouchPotatoSettings> cp,
                                 ISettingsService <SonarrSettings> sonarr, ISettingsService <SickRageSettings> sr, ISettingsService <HeadphonesSettings> hp, ISecurityExtensions security) : base("api", pr, security)
        {
            Get["GetVersion", "/version"] = x => GetVersion();


            Get["GetAuthSettings", "/settings/authentication"]   = x => GetAuthSettings();
            Post["PostAuthSettings", "/settings/authentication"] = x => PostAuthSettings();

            Get["GetPlexRequestSettings", "/settings/plexrequest"]   = x => GetPrSettings();
            Post["PostPlexRequestSettings", "/settings/plexrequest"] = x => PostPrSettings();

            Get["GetPlexSettings", "/settings/plex"]   = x => GetPlexSettings();
            Post["PostPlexSettings", "/settings/plex"] = x => PostPlexSettings();

            Get["GetCouchPotatoSettings", "/settings/couchpotato"]   = x => GetCpSettings();
            Post["PostCouchPotatoSettings", "/settings/couchpotato"] = x => PostCpSettings();

            Get["GetSonarrSettings", "/settings/sonarr"]   = x => GetSonarrSettings();
            Post["PostSonarrSettings", "/settings/sonarr"] = x => PostSonarrSettings();

            Get["GetSickRageSettings", "/settings/sickrage"]   = x => GetSickRageSettings();
            Post["PostSickRageSettings", "/settings/sickrage"] = x => PostSickRageSettings();

            Get["GetHeadphonesSettings", "/settings/headphones"]   = x => GetHeadphonesSettings();
            Post["PostHeadphonesSettings", "/settings/headphones"] = x => PostHeadphonesSettings();

            SettingsService    = pr;
            AuthSettings       = auth;
            PlexSettings       = plexSettings;
            CpSettings         = cp;
            SonarrSettings     = sonarr;
            SickRageSettings   = sr;
            HeadphonesSettings = hp;
        }
Esempio n. 22
0
 public DonationLinkModule(ICacheProvider provider, ISettingsService <PlexRequestSettings> pr, ISecurityExtensions security) : base("customDonation", pr, security)
 {
     Cache          = provider;
     Get["/", true] = async(x, ct) => await GetCustomDonationUrl(pr);
 }
Esempio n. 23
0
        public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi,
                                       ISickRageApi srApi, IHeadphonesApi hpApi, ISettingsService <PlexRequestSettings> pr, ISecurityExtensions security,
                                       IWatcherApi watcherApi) : base("test", pr, security)
        {
            this.RequiresAuthentication();

            CpApi         = cpApi;
            SonarrApi     = sonarrApi;
            PlexApi       = plexApi;
            SickRageApi   = srApi;
            HeadphonesApi = hpApi;
            WatcherApi    = watcherApi;

            Post["/cp"]         = _ => CouchPotatoTest();
            Post["/sonarr"]     = _ => SonarrTest();
            Post["/plex"]       = _ => PlexTest();
            Post["/sickrage"]   = _ => SickRageTest();
            Post["/headphones"] = _ => HeadphonesTest();
            Post["/plexdb"]     = _ => TestPlexDb();
            Post["/watcher"]    = _ => WatcherTest();
        }
Esempio n. 24
0
        public LandingPageModule(ISettingsService <PlexRequestSettings> settingsService, ISettingsService <LandingPageSettings> landing,
                                 ISettingsService <PlexSettings> ps, IPlexApi pApi, IResourceLinker linker, ISecurityExtensions security) : base("landing", settingsService, security)
        {
            LandingSettings = landing;
            PlexSettings    = ps;
            PlexApi         = pApi;
            Linker          = linker;

            Get["LandingPageIndex", "/", true] = async(x, ct) =>
            {
                var s = await LandingSettings.GetSettingsAsync();

                if (!s.BeforeLogin && string.IsNullOrEmpty(Username)) //We are signed in
                {
                    var url = Linker.BuildRelativeUri(Context, "SearchIndex").ToString();
                    return(Response.AsRedirect(url));
                }

                var model = new LandingPageViewModel
                {
                    Enabled           = s.Enabled,
                    Id                = s.Id,
                    EnabledNoticeTime = s.EnabledNoticeTime,
                    NoticeEnable      = s.NoticeEnable,
                    NoticeEnd         = s.NoticeEnd,
                    NoticeMessage     = s.NoticeMessage,
                    NoticeStart       = s.NoticeStart,
                    ContinueUrl       = s.BeforeLogin ? $"userlogin" : $"search"
                };
                return(View["Landing/Index", model]);
            };
            Get["/status", true] = async(x, ct) => await CheckStatus();
        }
Esempio n. 25
0
        public LayoutModule(ICacheProvider provider, ISettingsService <PlexRequestSettings> pr, ISettingsService <SystemSettings> settings, IJobRecord rec, ISecurityExtensions security, IUserHelper helper) : base("layout", pr, security)
        {
            Cache          = provider;
            SystemSettings = settings;
            Job            = rec;
            UserHelper     = helper;

            Get["/", true] = async(x, ct) => await CheckLatestVersion();

            Get["/cacher", true] = async(x, ct) => await CacherRunning();

            Get["/gravatar"] = x => GetGravatarImage();
        }
Esempio n. 26
0
        public ApiRequestModule(IRequestService service, ISettingsService <PlexRequestSettings> pr, ISecurityExtensions security) : base("api", pr, security)
        {
            Get["GetRequests", "/requests"]            = x => GetRequests();
            Get["GetRequest", "/requests/{id}"]        = x => GetSingleRequests(x);
            Post["PostRequests", "/requests"]          = x => CreateRequest();
            Put["PutRequests", "/requests"]            = x => UpdateRequest();
            Delete["DeleteRequests", "/requests/{id}"] = x => DeleteRequest(x);


            RequestService  = service;
            SettingsService = pr;
        }
Esempio n. 27
0
        public ApiUserModule(ISettingsService <PlexRequestSettings> pr, ICustomUserMapper m, ISecurityExtensions security) : base("api", pr, security)
        {
            Put["PutCredentials", "/credentials/{username}"] = x => ChangePassword(x);

            Get["GetApiKey", "/apikey"] = x => GetApiKey();

            SettingsService = pr;
            UserMapper      = m;
        }
Esempio n. 28
0
        public IssuesModule(ISettingsService <PlexRequestSettings> pr, IIssueService issueService, IRequestService request, INotificationService n, ISecurityExtensions security) : base("issues", pr, security)
        {
            IssuesService       = issueService;
            RequestService      = request;
            NotificationService = n;

            Get["/"] = x => Index();

            Get["/{id}", true] = async(x, ct) => await Details(x.id);

            Post["/issue", true] = async(x, ct) => await ReportRequestIssue((int)Request.Form.requestId, (IssueState)(int)Request.Form.issue, null);

            Get["/pending", true] = async(x, ct) => await GetIssues(IssueStatus.PendingIssue);

            Get["/resolved", true] = async(x, ct) => await GetIssues(IssueStatus.ResolvedIssue);

            Post["/remove", true] = async(x, ct) => await RemoveIssue((int)Request.Form.issueId);

            Post["/resolvedUpdate", true] = async(x, ct) => await ChangeStatus((int)Request.Form.issueId, IssueStatus.ResolvedIssue);

            Post["/clear", true] = async(x, ct) => await ClearIssue((int)Request.Form.issueId, (IssueState)(int)Request.Form.issue);

            Get["/issuecount", true] = async(x, ct) => await IssueCount();

            Get["/tabCount", true] = async(x, ct) => await TabCount();

            Post["/issuecomment", true] = async(x, ct) => await ReportRequestIssue((int)Request.Form.providerId, IssueState.Other, (string)Request.Form.commentArea);

            Post["/nonrequestissue", true] = async(x, ct) => await ReportNonRequestIssue((int)Request.Form.providerId, (string)Request.Form.type, (IssueState)(int)Request.Form.issue, null);

            Post["/nonrequestissuecomment", true] = async(x, ct) => await ReportNonRequestIssue((int)Request.Form.providerId, (string)Request.Form.type, IssueState.Other, (string)Request.Form.commentArea);


            Post["/addnote", true] = async(x, ct) => await AddNote((int)Request.Form.requestId, (string)Request.Form.noteArea, (IssueState)(int)Request.Form.issue);
        }
Esempio n. 29
0
        public IndexModule(ISettingsService <PlexRequestSettings> pr, ISettingsService <LandingPageSettings> l, IResourceLinker rl, ISecurityExtensions security) : base(pr, security)
        {
            LandingPage             = l;
            Linker                  = rl;
            Get["Index", "/", true] = async(x, ct) => await Index();

            Get["/Index", true] = async(x, ct) => await Index();
        }
Esempio n. 30
0
        public UserLoginModule(ISettingsService <AuthenticationSettings> auth, IPlexApi api, ISettingsService <PlexSettings> plexSettings, ISettingsService <PlexRequestSettings> pr,
                               ISettingsService <LandingPageSettings> lp, IAnalytics a, IResourceLinker linker, IRepository <UserLogins> userLogins, IExternalUserRepository <PlexUsers> plexUsers, ICustomUserMapper custom,
                               ISecurityExtensions security, ISettingsService <UserManagementSettings> userManagementSettings, IEmbyApi embyApi, ISettingsService <EmbySettings> emby, IExternalUserRepository <EmbyUsers> embyU,
                               IUserHelper userHelper)
            : base("userlogin", pr, security)
        {
            AuthService         = auth;
            LandingPageSettings = lp;
            Analytics           = a;
            PlexApi             = api;
            PlexSettings        = plexSettings;
            Linker                 = linker;
            UserLogins             = userLogins;
            PlexUserRepository     = plexUsers;
            CustomUserMapper       = custom;
            UserManagementSettings = userManagementSettings;
            EmbySettings           = emby;
            EmbyApi                = embyApi;
            EmbyUserRepository     = embyU;
            UserHelper             = userHelper;

            Post["/", true] = async(x, ct) => await LoginUser();

            Get["/logout"] = x => Logout();

            Get["UserLoginIndex", "/", true] = async(x, ct) =>
            {
                if (Request.Query["landing"] == null)
                {
                    var s = await LandingPageSettings.GetSettingsAsync();

                    if (s.Enabled)
                    {
                        if (s.BeforeLogin) // Before login
                        {
                            if (string.IsNullOrEmpty(Username))
                            {
                                // They are not logged in
                                return
                                    (Context.GetRedirect(Linker.BuildRelativeUri(Context, "LandingPageIndex").ToString()));
                            }
                            return(Context.GetRedirect(Linker.BuildRelativeUri(Context, "SearchIndex").ToString()));
                        }

                        // After login
                        if (string.IsNullOrEmpty(Username))
                        {
                            // Not logged in yet
                            return(Context.GetRedirect(Linker.BuildRelativeUri(Context, "UserLoginIndex").ToString() + "?landing"));
                        }
                        // Send them to landing
                        var landingUrl = Linker.BuildRelativeUri(Context, "LandingPageIndex").ToString();
                        return(Context.GetRedirect(landingUrl));
                    }
                }

                if (!string.IsNullOrEmpty(Username) || IsAdmin)
                {
                    var url = Linker.BuildRelativeUri(Context, "SearchIndex").ToString();
                    return(Response.AsRedirect(url));
                }
                var settings = await AuthService.GetSettingsAsync();

                return(View["Username", settings]);
            };

            Post["/login", true] = async(x, ct) => await UsernameLogin();

            Post["/password", true] = async(x, ct) => await PasswordLogin();
        }