Skip to content

Commit 5da7cc6

Browse files
committed
merge with fish but keep visibility collapsed until fish releases
1 parent 3a27a1a commit 5da7cc6

17 files changed

Lines changed: 200 additions & 79 deletions

File tree

Bloxstrap/AppData/CommonAppData.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ public abstract class CommonAppData
1010
{
1111
public virtual string ExecutableName { get; } = null!;
1212

13-
public string Directory => Path.Combine(Paths.Versions, String.IsNullOrEmpty(State.VersionGuid) ? "" : State.VersionGuid);
13+
public virtual string BinaryType { get; } = null!;
14+
15+
public string StaticDirectory => Path.Combine(Paths.Versions, BinaryType);
16+
public string DynamicDirectory => Path.Combine(Paths.Versions, State.VersionGuid);
17+
18+
public string Directory => App.Settings.Prop.StaticDirectory ? StaticDirectory : DynamicDirectory;
1419

1520
public string ExecutablePath => Path.Combine(Directory, ExecutableName);
1621

Bloxstrap/AppData/IAppData.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ internal interface IAppData
1010

1111
string ExecutableName { get; }
1212

13+
string StaticDirectory { get; }
14+
15+
string DynamicDirectory { get; }
16+
1317
string Directory { get; }
1418

1519
string ExecutablePath { get; }
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
using Bloxstrap;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
8-
namespace Bloxstrap.AppData
1+
namespace Bloxstrap.AppData
92
{
103
public class RobloxPlayerData : CommonAppData, IAppData
114
{
125
public string ProductName => "Roblox";
136

14-
public string BinaryType => "WindowsPlayer";
7+
public override string BinaryType => "WindowsPlayer";
158

169
public string RegistryName => "RobloxPlayer";
10+
1711
public override string ExecutableName => App.RobloxPlayerAppName;
12+
1813
public override AppState State => App.RobloxState.Prop.Player;
1914
}
2015
}

Bloxstrap/AppData/RobloxStudioData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public class RobloxStudioData : CommonAppData, IAppData
44
{
55
public string ProductName => "Roblox Studio";
66

7-
public string BinaryType => "WindowsStudio64";
7+
public override string BinaryType => "WindowsStudio64";
88

99
public string RegistryName => "RobloxStudio";
1010

Bloxstrap/Bootstrapper.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class Bootstrapper
5757
private string _latestVersionGuid = null!;
5858
private string _latestVersionDirectory = null!;
5959
private PackageManifest _versionPackageManifest = null!;
60+
public static bool _staticDirectory => App.Settings.Prop.StaticDirectory;
6061

6162
private bool _isInstalling = false;
6263
private double _progressIncrement;
@@ -485,7 +486,7 @@ private async Task GetLatestVersionInfo()
485486
// Private channels
486487
if (App.Cookies.Loaded)
487488
{
488-
UserChannel? userChannel = await App.Cookies.GetUserChannel(Deployment.BinaryType);
489+
UserChannel? userChannel = await Deployment.GetUserChannel(Deployment.BinaryType);
489490

490491
if (
491492
userChannel?.Token is not null &&
@@ -630,7 +631,10 @@ private async Task GetLatestVersionInfo()
630631
// we can't determine the version
631632
}
632633

633-
_latestVersionDirectory = Path.Combine(Paths.Versions, _latestVersionGuid);
634+
if (_staticDirectory)
635+
_latestVersionDirectory = AppData.StaticDirectory;
636+
else
637+
_latestVersionDirectory = Path.Combine(Paths.Versions, _latestVersionGuid);
634638

635639
string pkgManifestUrl = Deployment.GetLocation($"/{_latestVersionGuid}-rbxPkgManifest.txt");
636640
var pkgManifestData = await App.HttpClient.GetStringAsync(pkgManifestUrl);
@@ -1337,7 +1341,10 @@ public static void CleanupVersionsFolder()
13371341
{
13381342
string dirName = Path.GetFileName(dir);
13391343

1340-
if (dirName != App.RobloxState.Prop.Player.VersionGuid && dirName != App.RobloxState.Prop.Studio.VersionGuid)
1344+
if (
1345+
!_staticDirectory && (dirName != App.RobloxState.Prop.Player.VersionGuid && dirName != App.RobloxState.Prop.Studio.VersionGuid) ||
1346+
_staticDirectory && (dirName != "WindowsPlayer" && dirName != "WindowsStudio64")
1347+
)
13411348
{
13421349
// TODO: this is too expensive
13431350
//Filesystem.AssertReadOnlyDirectory(dir);
@@ -1350,7 +1357,7 @@ public static void CleanupVersionsFolder()
13501357
{
13511358
Directory.Delete(dir, true);
13521359
}
1353-
catch (IOException ex)
1360+
catch (Exception ex)
13541361
{
13551362
App.Logger.WriteLine(LOG_IDENT, $"Failed to delete {dir}");
13561363
App.Logger.WriteException(LOG_IDENT, ex);

Bloxstrap/CookiesManager.cs

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,62 +30,48 @@ public CookieState State
3030
private const string AuthPattern = $@"\t{AuthCookieName}\t(.+?)(;|$)";
3131
private string CookiesPath => Path.Combine(Paths.Roblox, "LocalStorage", "RobloxCookies.dat");
3232

33-
public async Task<AuthenticatedUser?> GetAuthenticated()
33+
public async Task<HttpResponseMessage> AuthRequest(HttpRequestMessage request)
3434
{
35-
const string LOG_IDENT = "CookiesManager::GetAuthenticated";
36-
37-
var request = new HttpRequestMessage()
38-
{
39-
Method = HttpMethod.Get,
40-
RequestUri = new Uri("https://users.roblox.com/v1/users/authenticated")
41-
};
35+
string? host = request.RequestUri?.Host;
4236

43-
request.Headers.Add("Cookie", $".ROBLOSECURITY={AuthCookie}");
37+
if (host is null)
38+
throw new ArgumentNullException("Host cannot be null");
4439

45-
try
46-
{
47-
HttpResponseMessage response = await App.HttpClient.SendAsync(request);
48-
response.EnsureSuccessStatusCode();
40+
if (
41+
!host.Equals("roblox.com", StringComparison.OrdinalIgnoreCase) &&
42+
!host.EndsWith(".roblox.com", StringComparison.OrdinalIgnoreCase)
43+
)
44+
throw new HttpRequestException("Host must end with roblox.com");
4945

50-
string content = await response.Content.ReadAsStringAsync();
51-
AuthenticatedUser user = JsonSerializer.Deserialize<AuthenticatedUser>(content)!;
46+
if (!Enabled)
47+
throw new NullReferenceException("Cookie access is not enabled");
5248

53-
return user;
54-
}
55-
catch (HttpRequestException ex)
56-
{
57-
App.Logger.WriteLine(LOG_IDENT, "Failed to get authenticated user");
58-
App.Logger.WriteException(LOG_IDENT, ex);
59-
}
49+
request.Headers.Add("Cookie", $".ROBLOSECURITY={AuthCookie}");
50+
var response = await App.HttpClient.SendAsync(request);
6051

61-
return null;
52+
return response;
6253
}
6354

64-
public async Task<UserChannel?> GetUserChannel(string binaryType)
65-
{
66-
const string LOG_IDENT = "CookiesManager::GetUserChannel";
67-
68-
var request = new HttpRequestMessage()
69-
{
70-
Method = HttpMethod.Get,
71-
RequestUri = new Uri($"https://clientsettings.roblox.com/v2/user-channel?binaryType={binaryType}")
72-
};
55+
public async Task<HttpResponseMessage> AuthGet(string uri) => await AuthRequest(new HttpRequestMessage { RequestUri = new Uri(uri), Method = HttpMethod.Get });
56+
public async Task<HttpResponseMessage> AuthPost(string uri, HttpContent? content) => await AuthRequest(new HttpRequestMessage { RequestUri = new Uri(uri), Content = content, Method = HttpMethod.Post });
7357

74-
request.Headers.Add("Cookie", $".ROBLOSECURITY={AuthCookie}");
58+
public async Task<AuthenticatedUser?> GetAuthenticated()
59+
{
60+
const string LOG_IDENT = "CookiesManager::GetAuthenticated";
7561

7662
try
7763
{
78-
HttpResponseMessage response = await App.HttpClient.SendAsync(request);
64+
HttpResponseMessage response = await AuthGet("https://users.roblox.com/v1/users/authenticated");
7965
response.EnsureSuccessStatusCode();
8066

8167
string content = await response.Content.ReadAsStringAsync();
82-
UserChannel channelInfo = JsonSerializer.Deserialize<UserChannel>(content)!;
68+
AuthenticatedUser user = JsonSerializer.Deserialize<AuthenticatedUser>(content)!;
8369

84-
return channelInfo;
70+
return user;
8571
}
8672
catch (HttpRequestException ex)
8773
{
88-
App.Logger.WriteLine(LOG_IDENT, "Failed to get user channel");
74+
App.Logger.WriteLine(LOG_IDENT, "Failed to get authenticated user");
8975
App.Logger.WriteException(LOG_IDENT, ex);
9076
}
9177

Bloxstrap/Integrations/PlayerDiscordRichPresence.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ public async Task<bool> SetCurrentGame()
356356
{
357357
await UniverseDetails.FetchSingle(activity.UniverseId);
358358
}
359+
catch (InvalidHTTPResponseException ex)
360+
{
361+
App.Logger.WriteLine(LOG_IDENT, $"Universe {activity.UniverseId} is restricted");
362+
App.Logger.WriteException(LOG_IDENT, ex);
363+
return false;
364+
}
359365
catch (Exception ex)
360366
{
361367
App.Logger.WriteException(LOG_IDENT, ex);

Bloxstrap/Models/APIs/Config/DatacentersCache.cs renamed to Bloxstrap/Models/DatacentersCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Bloxstrap.Models.APIs.Config
1+
namespace Bloxstrap.Models
22
{
33
public class DatacentersCache
44
{

Bloxstrap/Models/Entities/UniverseDetails.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ public class UniverseDetails
2828

2929
public static async Task FetchBulk(string ids)
3030
{
31-
var gameDetailResponse = await Http.GetJson<ApiArrayResponse<GameDetailResponse>>($"https://games.roblox.com/v1/games?universeIds={ids}");
31+
ApiArrayResponse<GameDetailResponse> gameDetailResponse;
32+
33+
// some universes can't be viewed by logged out user (ex. 18+)
34+
if (App.Cookies.Loaded)
35+
gameDetailResponse = await Http.AuthGetJson<ApiArrayResponse<GameDetailResponse>>($"https://games.roblox.com/v1/games?universeIds={ids}");
36+
else
37+
gameDetailResponse = await Http.GetJson<ApiArrayResponse<GameDetailResponse>>($"https://games.roblox.com/v1/games?universeIds={ids}");
3238

3339
if (!gameDetailResponse.Data.Any())
3440
throw new InvalidHTTPResponseException("Roblox API for Game Details returned invalid data");

Bloxstrap/Models/APIs/Config/GameHistoryData.cs renamed to Bloxstrap/Models/GameHistoryData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Bloxstrap.Models.APIs.Config
1+
namespace Bloxstrap.Models
22
{
33
public class GameHistoryData
44
{

0 commit comments

Comments
 (0)