Skip to content

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.

refactor(social): drop redundant \$account->refresh() after CV refresh

Paulo Castellano6c6078fa6a4a
diff --git a/app/Services/Social/BlueskyPublisher.php b/app/Services/Social/BlueskyPublisher.php
index bc7a5b65f..38094fc6e 100644
--- a/app/Services/Social/BlueskyPublisher.php
+++ b/app/Services/Social/BlueskyPublisher.php
@@ -30,7 +30,6 @@ class BlueskyPublisher
// Refresh token if needed
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$medias = $postPlatform->post->mediaItems;
diff --git a/app/Services/Social/ConnectionVerifier.php b/app/Services/Social/ConnectionVerifier.php
index a0b25dfb1..7f25319fa 100644
--- a/app/Services/Social/ConnectionVerifier.php
+++ b/app/Services/Social/ConnectionVerifier.php
@@ -99,9 +99,8 @@ class ConnectionVerifier
Platform::Pinterest => $this->refreshPinterestToken($account),
Platform::Threads => $this->refreshThreadsToken($account),
Platform::Instagram => $this->refreshInstagramToken($account),
- // InstagramFacebook uses page tokens that don't expire (like Facebook)
- // Mastodon tokens don't expire
- // Mastodon tokens don't expire
+ // Facebook / InstagramFacebook use Page tokens that don't expire.
+ // Mastodon tokens don't expire either.
default => null,
};
} finally {
diff --git a/app/Services/Social/InstagramAnalytics.php b/app/Services/Social/InstagramAnalytics.php
index de677310e..50c20c889 100644
--- a/app/Services/Social/InstagramAnalytics.php
+++ b/app/Services/Social/InstagramAnalytics.php
@@ -46,7 +46,6 @@ class InstagramAnalytics
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
@@ -90,7 +89,6 @@ class InstagramAnalytics
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/InstagramPublisher.php b/app/Services/Social/InstagramPublisher.php
index d4da82740..c22bef71a 100644
--- a/app/Services/Social/InstagramPublisher.php
+++ b/app/Services/Social/InstagramPublisher.php
@@ -31,7 +31,6 @@ class InstagramPublisher
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$instagramId = $account->platform_user_id;
diff --git a/app/Services/Social/LinkedInPageAnalytics.php b/app/Services/Social/LinkedInPageAnalytics.php
index 3fdba5499..71fb4355a 100644
--- a/app/Services/Social/LinkedInPageAnalytics.php
+++ b/app/Services/Social/LinkedInPageAnalytics.php
@@ -52,7 +52,6 @@ class LinkedInPageAnalytics
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
// platform_post_id is the share URN (e.g., "urn:li:share:12345").
@@ -82,7 +81,6 @@ class LinkedInPageAnalytics
{
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/LinkedInPagePublisher.php b/app/Services/Social/LinkedInPagePublisher.php
index 8269a21b5..c1a186f6e 100644
--- a/app/Services/Social/LinkedInPagePublisher.php
+++ b/app/Services/Social/LinkedInPagePublisher.php
@@ -47,7 +47,6 @@ class LinkedInPagePublisher
if ($this->account->is_token_expired || $this->account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($this->account);
- $this->account->refresh();
}
$this->accessToken = $this->account->access_token;
@@ -82,7 +81,6 @@ class LinkedInPagePublisher
try {
app(ConnectionVerifier::class)->refreshToken($this->account);
- $this->account->refresh();
$this->accessToken = $this->account->access_token;
$organizationId = $this->account->meta['organization_id'] ?? null;
diff --git a/app/Services/Social/LinkedInPublisher.php b/app/Services/Social/LinkedInPublisher.php
index 567bf1e03..8053d4588 100644
--- a/app/Services/Social/LinkedInPublisher.php
+++ b/app/Services/Social/LinkedInPublisher.php
@@ -47,7 +47,6 @@ class LinkedInPublisher
if ($this->account->is_token_expired || $this->account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($this->account);
- $this->account->refresh();
}
$this->accessToken = $this->account->access_token;
@@ -76,7 +75,6 @@ class LinkedInPublisher
try {
app(ConnectionVerifier::class)->refreshToken($this->account);
- $this->account->refresh();
$this->accessToken = $this->account->access_token;
$personUrn = "urn:li:person:{$this->account->platform_user_id}";
diff --git a/app/Services/Social/PinterestAnalytics.php b/app/Services/Social/PinterestAnalytics.php
index d18391a43..082963a24 100644
--- a/app/Services/Social/PinterestAnalytics.php
+++ b/app/Services/Social/PinterestAnalytics.php
@@ -48,7 +48,6 @@ class PinterestAnalytics
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$start = now()->subDays(90)->format('Y-m-d');
@@ -93,7 +92,6 @@ class PinterestAnalytics
{
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/PinterestPublisher.php b/app/Services/Social/PinterestPublisher.php
index 5fe1d7b33..994199fa5 100644
--- a/app/Services/Social/PinterestPublisher.php
+++ b/app/Services/Social/PinterestPublisher.php
@@ -35,7 +35,6 @@ class PinterestPublisher
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$content = $postPlatform->post->content ? app(ContentSanitizer::class)->sanitize($postPlatform->post->content, $postPlatform->platform) : null;
@@ -407,7 +406,6 @@ class PinterestPublisher
{
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$response = $this->socialHttp()->withToken($account->access_token)
diff --git a/app/Services/Social/ThreadsAnalytics.php b/app/Services/Social/ThreadsAnalytics.php
index 262589795..ef196477e 100644
--- a/app/Services/Social/ThreadsAnalytics.php
+++ b/app/Services/Social/ThreadsAnalytics.php
@@ -48,7 +48,6 @@ class ThreadsAnalytics
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$response = $this->socialHttp()
@@ -80,7 +79,6 @@ class ThreadsAnalytics
{
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/ThreadsPublisher.php b/app/Services/Social/ThreadsPublisher.php
index 28d3d19ab..c37402f18 100644
--- a/app/Services/Social/ThreadsPublisher.php
+++ b/app/Services/Social/ThreadsPublisher.php
@@ -31,7 +31,6 @@ class ThreadsPublisher
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$userId = $account->platform_user_id;
diff --git a/app/Services/Social/TikTokAnalytics.php b/app/Services/Social/TikTokAnalytics.php
index a1a80d634..378619783 100644
--- a/app/Services/Social/TikTokAnalytics.php
+++ b/app/Services/Social/TikTokAnalytics.php
@@ -37,7 +37,6 @@ class TikTokAnalytics
{
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/TikTokCreatorInfo.php b/app/Services/Social/TikTokCreatorInfo.php
index 418316bd0..7571d0672 100644
--- a/app/Services/Social/TikTokCreatorInfo.php
+++ b/app/Services/Social/TikTokCreatorInfo.php
@@ -60,7 +60,6 @@ class TikTokCreatorInfo
{
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/TikTokPublisher.php b/app/Services/Social/TikTokPublisher.php
index 554e3402e..d26a8a8a2 100644
--- a/app/Services/Social/TikTokPublisher.php
+++ b/app/Services/Social/TikTokPublisher.php
@@ -37,7 +37,6 @@ class TikTokPublisher
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/XAnalytics.php b/app/Services/Social/XAnalytics.php
index 1b22c7e98..c562b2a89 100644
--- a/app/Services/Social/XAnalytics.php
+++ b/app/Services/Social/XAnalytics.php
@@ -48,7 +48,6 @@ class XAnalytics
{
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
@@ -164,7 +163,6 @@ class XAnalytics
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/XPublisher.php b/app/Services/Social/XPublisher.php
index fefdda530..625a840b4 100644
--- a/app/Services/Social/XPublisher.php
+++ b/app/Services/Social/XPublisher.php
@@ -38,7 +38,6 @@ class XPublisher
// Refresh token if expired or expiring soon
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/YouTubeAnalytics.php b/app/Services/Social/YouTubeAnalytics.php
index 43d012481..c4eb83423 100644
--- a/app/Services/Social/YouTubeAnalytics.php
+++ b/app/Services/Social/YouTubeAnalytics.php
@@ -48,7 +48,6 @@ class YouTubeAnalytics
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
@@ -100,7 +99,6 @@ class YouTubeAnalytics
{
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$this->accessToken = $account->access_token;
diff --git a/app/Services/Social/YouTubePublisher.php b/app/Services/Social/YouTubePublisher.php
index b3a68fd6b..5b4467c57 100644
--- a/app/Services/Social/YouTubePublisher.php
+++ b/app/Services/Social/YouTubePublisher.php
@@ -35,7 +35,6 @@ class YouTubePublisher
if ($account->is_token_expired || $account->is_token_expiring_soon) {
app(ConnectionVerifier::class)->refreshToken($account);
- $account->refresh();
}
$media = $postPlatform->post->mediaItems;