Skip to content

Commit 1871d0f

Browse files
Mindaugas VeblauskasThomas Felices
authored andcommitted
Add timezone to API calls [VPNWIN-2702]
1 parent 3509a13 commit 1871d0f

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
<PackageVersion Include="System.Text.Json" Version="9.0.1" />
9191
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.0" />
9292
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
93+
<PackageVersion Include="TimeZoneConverter" Version="7.0.0" />
9394
<PackageVersion Include="Vanara.PInvoke.PowrProf" Version="4.0.4" />
9495
<PackageVersion Include="Vanara.PInvoke.Security" Version="4.0.4" />
9596
<PackageVersion Include="Vanara.PInvoke.User32" Version="4.0.4" />

src/Api/ProtonVPN.Api/BaseApiClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
using ProtonVPN.Configurations.Contracts;
3535
using ProtonVPN.Logging.Contracts;
3636
using ProtonVPN.Logging.Contracts.Events.ApiLogs;
37+
using TimeZoneConverter;
3738

3839
namespace ProtonVPN.Api;
3940

@@ -163,6 +164,16 @@ protected HttpRequestMessage GetUnauthorizedRequest(HttpMethod method, string re
163164
request.Headers.Add("x-pm-appversion", _appVersion.AppVersion);
164165
request.Headers.Add("x-pm-locale", Settings.Language);
165166
request.Headers.Add("User-Agent", _appVersion.UserAgent);
167+
168+
try
169+
{
170+
request.Headers.Add("x-pm-timezone", TZConvert.WindowsToIana(TimeZoneInfo.Local.Id));
171+
}
172+
catch (Exception e)
173+
{
174+
Logger.Error<ApiLog>("Failed to set x-pm-timezone header", e);
175+
}
176+
166177
return request;
167178
}
168179

src/Api/ProtonVPN.Api/ProtonVPN.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
<PackageReference Include="System.Formats.Asn1" />
3131
<PackageReference Include="System.Net.Http" />
3232
<PackageReference Include="System.Text.Json" />
33+
<PackageReference Include="TimeZoneConverter" />
3334
</ItemGroup>
3435
</Project>

src/Client/ProtonVPN.Client/UI/Main/Settings/Pages/About/LicensingPageView.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>.
209209
<Hyperlink NavigateUri="https://raw.githubusercontent.com/getsentry/sentry-dotnet/master/LICENSE">The MIT License</Hyperlink>
210210
<Run/>
211211
</Paragraph>
212+
<Paragraph TextIndent="20">
213+
214+
<Hyperlink NavigateUri="https://github.com/mattjohnsonpint/TimeZoneConverter">TimeZoneConverter</Hyperlink> by Matt Johnson-Pint |
215+
<Hyperlink NavigateUri="https://github.com/mattjohnsonpint/TimeZoneConverter/blob/main/LICENSE.txt">The MIT License</Hyperlink>
216+
<Run/>
217+
</Paragraph>
212218
<Paragraph TextIndent="20">
213219
214220
<Hyperlink NavigateUri="https://github.com/dahall/vanara">Vanara</Hyperlink> by David Hall |

0 commit comments

Comments
 (0)