mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
fix(wizard): 🐛 Fixed the issue where the Application Url wasn't validated in the wizard
#4417
This commit is contained in:
parent
5c691dc984
commit
33b8d1111a
3 changed files with 43 additions and 22 deletions
|
@ -310,15 +310,17 @@ namespace Ombi.Core.Senders
|
||||||
private async Task SendToSonarr(ChildRequests model, SonarrSeries result, SonarrSettings s)
|
private async Task SendToSonarr(ChildRequests model, SonarrSeries result, SonarrSettings s)
|
||||||
{
|
{
|
||||||
// Check to ensure we have the all the seasons, ensure the Sonarr metadata has grabbed all the data
|
// Check to ensure we have the all the seasons, ensure the Sonarr metadata has grabbed all the data
|
||||||
|
Season existingSeason = null;
|
||||||
foreach (var season in model.SeasonRequests)
|
foreach (var season in model.SeasonRequests)
|
||||||
{
|
{
|
||||||
var attempt = 0;
|
var attempt = 0;
|
||||||
var existingSeason = result.seasons.FirstOrDefault(x => x.seasonNumber == season.SeasonNumber);
|
existingSeason = result.seasons.FirstOrDefault(x => x.seasonNumber == season.SeasonNumber);
|
||||||
while (existingSeason == null && attempt < 5)
|
while (existingSeason == null && attempt < 5)
|
||||||
{
|
{
|
||||||
attempt++;
|
attempt++;
|
||||||
Logger.LogInformation("There was no season numer {0} in Sonarr for title {1}. Will try again as the metadata did not get created", season.SeasonNumber, model.ParentRequest.Title);
|
Logger.LogInformation("There was no season numer {0} in Sonarr for title {1}. Will try again as the metadata did not get created", season.SeasonNumber, model.ParentRequest.Title);
|
||||||
result = await SonarrApi.GetSeriesById(result.id, s.ApiKey, s.FullUri);
|
result = await SonarrApi.GetSeriesById(result.id, s.ApiKey, s.FullUri);
|
||||||
|
existingSeason = result.seasons.FirstOrDefault(x => x.seasonNumber == season.SeasonNumber);
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +350,7 @@ namespace Ombi.Core.Senders
|
||||||
foreach (var ep in season.Episodes)
|
foreach (var ep in season.Episodes)
|
||||||
{
|
{
|
||||||
var sonarrEp = sonarrEpList.FirstOrDefault(x =>
|
var sonarrEp = sonarrEpList.FirstOrDefault(x =>
|
||||||
x.episodeNumber == ep.EpisodeNumber && x.seasonNumber == req.SeasonNumber);
|
x.episodeNumber == ep.EpisodeNumber && x.seasonNumber == season.SeasonNumber);
|
||||||
if (sonarrEp != null && !sonarrEp.monitored)
|
if (sonarrEp != null && !sonarrEp.monitored)
|
||||||
{
|
{
|
||||||
sonarrEp.monitored = true;
|
sonarrEp.monitored = true;
|
||||||
|
@ -369,8 +371,6 @@ namespace Ombi.Core.Senders
|
||||||
//var missingEpisodes = Enumerable.Range(distinctEpisodes.Min(), distinctEpisodes.Count).Except(distinctEpisodes);
|
//var missingEpisodes = Enumerable.Range(distinctEpisodes.Min(), distinctEpisodes.Count).Except(distinctEpisodes);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (sonarrEpCount == ourRequestCount /*|| !missingEpisodes.Any()*/)
|
if (sonarrEpCount == ourRequestCount /*|| !missingEpisodes.Any()*/)
|
||||||
{
|
{
|
||||||
// We have the same amount of requests as all of the episodes in the season.
|
// We have the same amount of requests as all of the episodes in the season.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { AfterViewInit, Component, OnInit, ViewChild } from "@angular/core";
|
import { AfterViewInit, Component, OnInit, ViewChild } from "@angular/core";
|
||||||
import { Router } from "@angular/router";
|
import { IdentityService, NotificationService, SettingsService } from "../../services";
|
||||||
|
|
||||||
import { ICreateWizardUser } from "../../interfaces";
|
import { ICreateWizardUser } from "../../interfaces";
|
||||||
import { IdentityService, NotificationService } from "../../services";
|
|
||||||
import { IOmbiConfigModel } from "../models/OmbiConfigModel";
|
import { IOmbiConfigModel } from "../models/OmbiConfigModel";
|
||||||
import { WizardService } from "../services/wizard.service";
|
|
||||||
import { MatHorizontalStepper } from'@angular/material/stepper';
|
import { MatHorizontalStepper } from'@angular/material/stepper';
|
||||||
import { StepperSelectionEvent } from "@angular/cdk/stepper";
|
import { Router } from "@angular/router";
|
||||||
|
import { WizardService } from "../services/wizard.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./welcome.component.html",
|
templateUrl: "./welcome.component.html",
|
||||||
|
@ -18,7 +18,8 @@ export class WelcomeComponent implements OnInit {
|
||||||
public config: IOmbiConfigModel;
|
public config: IOmbiConfigModel;
|
||||||
|
|
||||||
constructor(private router: Router, private identityService: IdentityService,
|
constructor(private router: Router, private identityService: IdentityService,
|
||||||
private notificationService: NotificationService, private WizardService: WizardService) { }
|
private notificationService: NotificationService, private WizardService: WizardService,
|
||||||
|
private settingsService: SettingsService) { }
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
this.localUser = {
|
this.localUser = {
|
||||||
|
@ -34,20 +35,39 @@ export class WelcomeComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public createUser() {
|
public createUser() {
|
||||||
this.WizardService.addOmbiConfig(this.config).subscribe(config => {
|
if (this.config.applicationUrl) {
|
||||||
if(config != null) {
|
this.settingsService.verifyUrl(this.config.applicationUrl).subscribe(x => {
|
||||||
this.identityService.createWizardUser(this.localUser).subscribe(x => {
|
if (!x) {
|
||||||
if (x.result) {
|
this.notificationService.error(`The URL "${this.config.applicationUrl}" is not valid. Please format it correctly e.g. http://www.google.com/`);
|
||||||
// save the config
|
this.stepper.selectedIndex = 3;
|
||||||
this.router.navigate(["login"]);
|
return;
|
||||||
|
}
|
||||||
|
this.saveConfig();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (x.errors.length > 0) {
|
this.saveConfig();
|
||||||
this.notificationService.error(x.errors[0]);
|
|
||||||
this.stepper.previous();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, configErr => this.notificationService.error(configErr));
|
|
||||||
|
private saveConfig() {
|
||||||
|
this.WizardService.addOmbiConfig(this.config).subscribe({
|
||||||
|
next: (config) => {
|
||||||
|
if(config != null) {
|
||||||
|
this.identityService.createWizardUser(this.localUser).subscribe(x => {
|
||||||
|
if (x.result) {
|
||||||
|
// save the config
|
||||||
|
this.router.navigate(["login"]);
|
||||||
|
} else {
|
||||||
|
if (x.errors.length > 0) {
|
||||||
|
this.notificationService.error(x.errors[0]);
|
||||||
|
this.stepper.previous();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (configErr) => this.notificationService.error(configErr)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,6 +334,7 @@ namespace Ombi.Controllers.V1
|
||||||
|
|
||||||
[ApiExplorerSettings(IgnoreApi = true)]
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
[HttpPost("customization/urlverify")]
|
[HttpPost("customization/urlverify")]
|
||||||
|
[AllowAnonymous]
|
||||||
public bool VerifyUrl([FromBody]UrlVerifyModel url)
|
public bool VerifyUrl([FromBody]UrlVerifyModel url)
|
||||||
{
|
{
|
||||||
return Uri.TryCreate(url.Url, UriKind.Absolute, out var __);
|
return Uri.TryCreate(url.Url, UriKind.Absolute, out var __);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue