mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-11 13:32:42 +01:00
2c93a27962
Added testing of SMTP settings to the settings page. Cleaned up some extraneous lines of JS and HTML.
83 lines
3.1 KiB
C#
83 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using NLog;
|
|
using NzbDrone.Core.Model;
|
|
using NzbDrone.Core.Providers;
|
|
using NzbDrone.Core.Providers.Jobs;
|
|
using NzbDrone.Web.Models;
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
{
|
|
public class CommandController : Controller
|
|
{
|
|
private readonly JobProvider _jobProvider;
|
|
private readonly SabProvider _sabProvider;
|
|
private readonly SmtpProvider _smtpProvider;
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
public CommandController(JobProvider jobProvider, SabProvider sabProvider,
|
|
SmtpProvider smtpProvider)
|
|
{
|
|
_jobProvider = jobProvider;
|
|
_sabProvider = sabProvider;
|
|
_smtpProvider = smtpProvider;
|
|
}
|
|
|
|
public JsonResult RssSync()
|
|
{
|
|
_jobProvider.QueueJob(typeof(RssSyncJob));
|
|
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
|
}
|
|
|
|
public JsonResult BacklogSearch()
|
|
{
|
|
_jobProvider.QueueJob(typeof(BacklogSearchJob));
|
|
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
|
}
|
|
|
|
public JsonResult SyncEpisodesOnDisk(int seriesId)
|
|
{
|
|
//Syncs the episodes on disk for the specified series
|
|
_jobProvider.QueueJob(typeof(DiskScanJob), seriesId);
|
|
|
|
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
|
}
|
|
|
|
public JsonResult UpdateInfo(int seriesId)
|
|
{
|
|
//Syncs the episodes on disk for the specified series
|
|
_jobProvider.QueueJob(typeof(UpdateInfoJob), seriesId);
|
|
|
|
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult GetSabnzbdCategories(string host, int port, string apiKey, string username, string password)
|
|
{
|
|
try
|
|
{
|
|
return new JsonResult {Data = _sabProvider.GetCategories(host, port, apiKey, username, password)};
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Warn("Unable to get Categories from SABnzbd");
|
|
Logger.DebugException(ex.Message, ex);
|
|
return Json(new NotificationResult { Title = "Failed", Text = "Unable to get SABnzbd Categories", NotificationType = NotificationType.Error });
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult SendTestEmail(string server, int port, bool ssl, string username, string password, string fromAddress, string toAddresses)
|
|
{
|
|
if (_smtpProvider.SendTestEmail(server, port, ssl, username, password, fromAddress, toAddresses))
|
|
return Json(new NotificationResult { Title = "Successfully sent test email." });
|
|
|
|
return Json(new NotificationResult { Title = "Failed", Text = "Unable to send Email, please check your settings", NotificationType = NotificationType.Error });
|
|
}
|
|
}
|
|
}
|