Skip to content

Commit

Permalink
🐛 FIX: Constellix per page
Browse files Browse the repository at this point in the history
  • Loading branch information
austinginder committed Jan 21, 2025
1 parent 3fc17f9 commit e3241c3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion app/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,12 @@ public function set_nameservers( $nameservers = [] ) {
public static function zone( $domain_id ) {
$domain = ( new Domains )->get( $domain_id );
$domain_info = Remote\Constellix::get( "domains/$domain->remote_id" );
$records = Remote\Constellix::get( "domains/$domain->remote_id/records" );
$records = Remote\Constellix::get( "domains/$domain->remote_id/records", [ "perPage" => 100 ] );
$steps = ceil( $records->meta->pagination->total / 100 );
for ($i = 1; $i < $steps; $i++) {
$additional_records = Remote\Constellix::get( "domains/$domain->remote_id/records", [ "page" => $i + 1, "perPage" => 100 ] );
$records->data = array_merge($records->data, $additional_records->data);
}
$zone = new \Badcow\DNS\Zone( $domain->name .'.');
$zone->setDefaultTtl(3600);
$zone_record = new \Badcow\DNS\ResourceRecord;
Expand Down
16 changes: 11 additions & 5 deletions captaincore.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,14 +859,20 @@ function captaincore_dns_func( $request ) {
}
$remote_id = ( new CaptainCore\Domains )->get( $domain_id )->remote_id;

$domain = CaptainCore\Remote\Constellix::get( "domains/$remote_id" );
$response = CaptainCore\Remote\Constellix::get( "domains/$remote_id/records?perPage=100" );
if ( ! $response->errors ) {
array_multisort( array_column( $response->data, 'type' ), SORT_ASC, array_column( $response->data, 'name' ), SORT_ASC, $response->data );
$domain = CaptainCore\Remote\Constellix::get( "domains/$remote_id" );
$records = CaptainCore\Remote\Constellix::get( "domains/$remote_id/records?perPage=100" );
$steps = ceil( $records->meta->pagination->total / 100 );
for ($i = 1; $i < $steps; $i++) {
$additional_records = CaptainCore\Remote\Constellix::get( "domains/$remote_id/records", [ "page" => $i + 1, "perPage" => 100 ] );
$records->data = array_merge($records->data, $additional_records->data);
}

if ( ! $records->errors ) {
array_multisort( array_column( $records->data, 'type' ), SORT_ASC, array_column( $records->data, 'name' ), SORT_ASC, $records->data );
}

return [
"records" => $response->data,
"records" => $records->data,
"nameservers" => $domain->data->nameservers
];
}
Expand Down

0 comments on commit e3241c3

Please sign in to comment.