Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1557

Merged
merged 2 commits into from
Oct 14, 2024
Merged

Develop #1557

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IIssueKeys
string FleetApiTokenRequestExpired { get; }
string FleetApiTokenNotReceived { get; }
string FleetApiTokenExpired { get; }
string FleetApiTokenRefreshNonSuccessStatusCode { get; }
string FleetApiTokenNoApiRequestsAllowed { get; }
string CrashedOnStartup { get; }
string RestartNeeded { get; }
Expand All @@ -19,7 +20,6 @@ public interface IIssueKeys
string FleetApiNonSuccessStatusCode { get; }
string FleetApiNonSuccessResult { get; }
string UnsignedCommand { get; }
string FleetApiTokenRefreshNonSuccessStatusCode { get; }
string CarRateLimited { get; }
string BleCommandNoSuccess { get; }
string SolarValuesNotAvailable { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class IssueKeys : IIssueKeys
public string FleetApiTokenMissingScopes => "FleetApiTokenMissingScopes";
public string FleetApiTokenRequestExpired => "FleetApiTokenRequestExpired";
public string FleetApiTokenNotReceived => "FleetApiTokenNotReceived";
public string FleetApiTokenRefreshNonSuccessStatusCode => "FleetApiTokenRefreshNonSuccessStatusCode";
public string FleetApiTokenExpired => "FleetApiTokenExpired";
public string FleetApiTokenNoApiRequestsAllowed => "FleetApiRequestsNotAllowed";
public string CrashedOnStartup => "CrashedOnStartup";
Expand All @@ -21,7 +22,6 @@ public class IssueKeys : IIssueKeys
public string FleetApiNonSuccessStatusCode => "FleetApiNonSuccessStatusCode_";
public string FleetApiNonSuccessResult => "FleetApiNonSuccessResult_";
public string UnsignedCommand => "UnsignedCommand";
public string FleetApiTokenRefreshNonSuccessStatusCode => "FleetApiTokenRefreshNonSuccessStatusCode";
public string CarRateLimited => "CarRateLimited";
public string BleCommandNoSuccess => "BleCommandNoSuccess_";
public string SolarValuesNotAvailable => "SolarValuesNotAvailable";
Expand Down
10 changes: 8 additions & 2 deletions TeslaSolarCharger/Server/Services/BackendApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public async Task<DtoValue<string>> StartTeslaOAuth(string locale, string baseUr
logger.LogTrace("{method}()", nameof(StartTeslaOAuth));
var currentTokens = await teslaSolarChargerContext.TeslaTokens.ToListAsync().ConfigureAwait(false);
teslaSolarChargerContext.TeslaTokens.RemoveRange(currentTokens);
var cconfigEntriesToRemove = await teslaSolarChargerContext.TscConfigurations
var configEntriesToRemove = await teslaSolarChargerContext.TscConfigurations
.Where(c => c.Key == constants.TokenMissingScopes)
.ToListAsync().ConfigureAwait(false);
teslaSolarChargerContext.TscConfigurations.RemoveRange(cconfigEntriesToRemove);
teslaSolarChargerContext.TscConfigurations.RemoveRange(configEntriesToRemove);
await teslaSolarChargerContext.SaveChangesAsync().ConfigureAwait(false);
var installationId = await tscConfigurationService.GetInstallationId().ConfigureAwait(false);
var backendApiBaseUrl = configurationWrapper.BackendApiBaseUrl();
Expand Down Expand Up @@ -63,7 +63,13 @@ public async Task<DtoValue<string>> StartTeslaOAuth(string locale, string baseUr
await errorHandlingService.HandleError(nameof(BackendApiService), nameof(StartTeslaOAuth), "Waiting for Tesla token",
"Waiting for the Tesla Token from the TSC backend. This might take up to five minutes. If after five minutes this error is still displayed, open the <a href=\"/BaseConfiguration\">Base Configuration</a> and request a new token.",
issueKeys.FleetApiTokenNotReceived, null, null);
//Do not set FleetApiTokenNotReceived to resolved here, as the token might still be in transit
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenNotRequested, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenUnauthorized, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenMissingScopes, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenRequestExpired, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenExpired, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenRefreshNonSuccessStatusCode, null);
return new DtoValue<string>(requestUrl);
}

Expand Down
Loading