Fixed shared domain loading
This commit is contained in:
@@ -5,6 +5,7 @@ using CloudFlare.Client.Api.Parameters.Data;
|
|||||||
using CloudFlare.Client.Api.Result;
|
using CloudFlare.Client.Api.Result;
|
||||||
using CloudFlare.Client.Api.Zones;
|
using CloudFlare.Client.Api.Zones;
|
||||||
using CloudFlare.Client.Api.Zones.DnsRecord;
|
using CloudFlare.Client.Api.Zones.DnsRecord;
|
||||||
|
using CloudFlare.Client.Client.Zones;
|
||||||
using CloudFlare.Client.Enumerators;
|
using CloudFlare.Client.Enumerators;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Moonlight.App.Database.Entities;
|
using Moonlight.App.Database.Entities;
|
||||||
@@ -82,12 +83,27 @@ public class DomainService
|
|||||||
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
if (!ConfigService.Get().Moonlight.Domains.Enable)
|
||||||
return Array.Empty<Zone>();
|
return Array.Empty<Zone>();
|
||||||
|
|
||||||
var domains = GetData(
|
var domains = new List<Zone>();
|
||||||
await Client.Zones.GetAsync(new()
|
|
||||||
{
|
var initialResponse = await Client.Zones.GetAsync();
|
||||||
AccountId = AccountId
|
|
||||||
})
|
domains.AddRange(GetData(initialResponse));
|
||||||
);
|
|
||||||
|
// Check if there are more pages
|
||||||
|
while (initialResponse.ResultInfo.Page < initialResponse.ResultInfo.TotalPage)
|
||||||
|
{
|
||||||
|
// Get the next page of data
|
||||||
|
var nextPageResponse = await Client.Zones.GetAsync(
|
||||||
|
displayOptions: new()
|
||||||
|
{
|
||||||
|
Page = initialResponse.ResultInfo.Page + 1
|
||||||
|
}
|
||||||
|
);
|
||||||
|
var nextPageZones = GetData(nextPageResponse);
|
||||||
|
|
||||||
|
domains.AddRange(nextPageZones);
|
||||||
|
initialResponse = nextPageResponse;
|
||||||
|
}
|
||||||
|
|
||||||
var sharedDomains = SharedDomainRepository.Get().ToArray();
|
var sharedDomains = SharedDomainRepository.Get().ToArray();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user