Major refactor #141

Merged
sim0n00ps merged 55 commits from whimsical-c4lic0/OF-DL:refactor-architecture into master 2026-02-13 00:21:58 +00:00
Showing only changes of commit a9a4c2ee20 - Show all commits

View File

@ -147,6 +147,12 @@ public class ApiService(IAuthService authService, IConfigService configService,
return headers;
}
private bool HasSignedRequestAuth()
{
Auth? currentAuth = authService.CurrentAuth;
return currentAuth is { UserId: not null, Cookie: not null, UserAgent: not null, XBc: not null };
}
/// <summary>
/// Retrieves user information from the API.
@ -157,6 +163,11 @@ public class ApiService(IAuthService authService, IConfigService configService,
{
Log.Debug($"Calling GetUserInfo: {endpoint}");
if (!HasSignedRequestAuth())
{
return null;
}
try
{
UserEntities.User user = new();
@ -197,6 +208,11 @@ public class ApiService(IAuthService authService, IConfigService configService,
/// <returns>A JSON object when available.</returns>
public async Task<JObject?> GetUserInfoById(string endpoint)
{
if (!HasSignedRequestAuth())
{
return null;
}
try
{
HttpClient client = new();
@ -272,6 +288,11 @@ public class ApiService(IAuthService authService, IConfigService configService,
{
Log.Debug("Calling GetLists");
if (!HasSignedRequestAuth())
{
return null;
}
try
{
int offset = 0;
@ -333,6 +354,11 @@ public class ApiService(IAuthService authService, IConfigService configService,
{
Log.Debug($"Calling GetListUsers - {endpoint}");
if (!HasSignedRequestAuth())
{
return null;
}
try
{
int offset = 0;
@ -393,6 +419,11 @@ public class ApiService(IAuthService authService, IConfigService configService,
{
Log.Debug($"Calling GetMedia - {username}");
if (!HasSignedRequestAuth())
{
return null;
}
try
{
Dictionary<long, string> returnUrls = new();
@ -2928,6 +2959,11 @@ public class ApiService(IAuthService authService, IConfigService configService,
private async Task<Dictionary<string, long>?> GetAllSubscriptions(Dictionary<string, string> getParams,
string endpoint, bool includeRestricted)
{
if (!HasSignedRequestAuth())
{
return null;
}
try
{
Dictionary<string, long> users = new();