Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
Page through all Pinterest boards until the bookmark ends.
Paulo Castellano491895cbd9a7
diff --git a/app/Services/Social/PinterestPublisher.php b/app/Services/Social/PinterestPublisher.phpindex 6efa47b0b..dbbf57430 100644--- a/app/Services/Social/PinterestPublisher.php+++ b/app/Services/Social/PinterestPublisher.php@@ -405,7 +405,8 @@ class PinterestPublisher}/**- * Get user's boards for board selection (follows Pinterest bookmark pagination).+ * Get user's boards for board selection (follows Pinterest bookmark pagination+ * until the API stops returning a bookmark).** @return list<array<string, mixed>>*/@@ -417,9 +418,23 @@ class PinterestPublisher$boards = [];$bookmark = null;- $maxPages = 20;+ $pages = 0;+ // Absurd ceiling only — normal accounts exit when bookmark is blank.+ $maxPages = 1000;++ while (true) {+ $pages++;++ if ($pages > $maxPages) {+ Log::warning('Pinterest get boards hit safety page cap', [+ 'account_id' => $account->id,+ 'pages' => $pages,+ 'boards' => count($boards),+ ]);++ break;+ }- for ($page = 0; $page < $maxPages; $page++) {$query = ['page_size' => 100];if (filled($bookmark)) {@@ -441,11 +456,23 @@ class PinterestPublisherarray_push($boards, ...$items);}- $bookmark = data_get($payload, 'bookmark');+ $nextBookmark = data_get($payload, 'bookmark');++ if (blank($nextBookmark)) {+ break;+ }++ if ($nextBookmark === $bookmark) {+ Log::warning('Pinterest get boards returned a repeated bookmark', [+ 'account_id' => $account->id,+ 'pages' => $pages,+ 'boards' => count($boards),+ ]);- if (blank($bookmark)) {break;}++ $bookmark = $nextBookmark;}return $boards;diff --git a/tests/Feature/Services/Social/PinterestPublisherTest.php b/tests/Feature/Services/Social/PinterestPublisherTest.phpindex e2d62ef3a..1d5b9ac54 100644--- a/tests/Feature/Services/Social/PinterestPublisherTest.php+++ b/tests/Feature/Services/Social/PinterestPublisherTest.php@@ -531,14 +531,45 @@ test('pinterest publisher paginates boards via bookmark', function () {'items' => [['id' => 'board_2', 'name' => 'Board 2'],],+ 'bookmark' => 'page-3',+ ], 200)+ ->push([+ 'items' => [+ ['id' => 'board_3', 'name' => 'Board 3'],+ ],], 200),]);$boards = $this->publisher->getBoards($this->socialAccount);- expect($boards)->toHaveCount(2)+ expect($boards)->toHaveCount(3)->and($boards[0]['id'])->toBe('board_1')- ->and($boards[1]['id'])->toBe('board_2');+ ->and($boards[1]['id'])->toBe('board_2')+ ->and($boards[2]['id'])->toBe('board_3');++ Http::assertSentCount(3);+});++test('pinterest publisher stops board pagination on a repeated bookmark', function () {+ Http::fake([+ config('trypost.platforms.pinterest.api').'/boards*' => Http::sequence()+ ->push([+ 'items' => [['id' => 'board_1', 'name' => 'Board 1']],+ 'bookmark' => 'stuck',+ ], 200)+ ->push([+ 'items' => [['id' => 'board_2', 'name' => 'Board 2']],+ 'bookmark' => 'stuck',+ ], 200)+ ->push([+ 'items' => [['id' => 'should_not_fetch', 'name' => 'Nope']],+ ], 200),+ ]);++ $boards = $this->publisher->getBoards($this->socialAccount);++ expect($boards)->toHaveCount(2)+ ->and(collect($boards)->pluck('id')->all())->toBe(['board_1', 'board_2']);Http::assertSentCount(2);});