trypost/app/Models
Paulo Castellano 1bb67b7abb Keep Instagram/Threads tokens extended while still valid
Cold review caught a regression from the two previous commits. Instagram and
Threads use long-lived tokens refreshed by EXTENDING the access_token itself
(grant_type=ig_refresh_token / th_refresh_token) — they have no separate
refresh_token and CANNOT be refreshed once expired. The anti-over-rotation rule
("only refresh a token once it's actually expired") is right for rotating
single-use refresh_token platforms but wrong for these: it left IG/Threads
tokens to lapse, after which the extend call fails and the account disconnects
(~every 60 days).

Gate the anti-rotation on the platform's refresh model:
- Platform::extendsAccessTokenOnRefresh() — true for Instagram/Threads.
- SocialAccount::needsProactiveTokenRefresh() — expired for rotating platforms,
  OR expiring-soon for extension platforms (restores isTokenExpiringSoon).
- RefreshSocialToken extends (refreshToken) extension-model tokens while still
  valid, and verifies (access-token-first) rotating ones.
- All 23 publisher/analytics pre-checks now use needsProactiveTokenRefresh().

Tests: proactive job extends a still-valid Instagram token; a model test covers
the rotating-vs-extension branching; existing X/LinkedIn anti-rotation tests
are unchanged.

Refs #126
2026-07-03 09:18:45 -03:00
..
Traits refactor(media): centralize image/video/document detection in Media\Type 2026-06-25 10:57:57 -03:00
AccessToken.php feat: migrate custom API token implementation to Laravel Passport for authentication and token management 2026-05-03 18:38:17 -03:00
Account.php refactor(billing): replace MonthlyCreditsLimit Pennant feature with BillingCycle 2026-06-22 09:55:03 -03:00
AiUsageLog.php feat: per-workspace pricing, onboarding, and billing overhaul 2026-06-21 20:40:03 -03:00
Automation.php Denormalize automation trigger_type into an indexed column 2026-06-13 15:26:54 -03:00
AutomationNodeRun.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
AutomationNodeState.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
AutomationRun.php Tidy automation backend: run duration, folded migrations, imports 2026-06-13 16:30:32 -03:00
AutomationTriggerItem.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
Invite.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
Media.php refactor(media): centralize image/video/document detection in Media\Type 2026-06-25 10:57:57 -03:00
Notification.php feat: notification system with SendNotification job, dialog UI, tests 2026-03-30 16:47:03 -03:00
NotificationPreference.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
Plan.php feat: per-workspace pricing, onboarding, and billing overhaul 2026-06-21 20:40:03 -03:00
Post.php refactor(social): trim verbose comments + harden X chunked upload from review 2026-06-28 20:37:04 -03:00
PostComment.php feat: add post_comments table, model, and factory 2026-04-15 20:08:16 -03:00
PostPlatform.php fix(facebook): empty-message rejection + state consistency + no re-publish on terminal 2026-05-19 12:47:18 -03:00
SocialAccount.php Keep Instagram/Threads tokens extended while still valid 2026-07-03 09:18:45 -03:00
Subscription.php feat: Implement soft deletes for workspace hashtags and labels, and integrate content_type into the initial post platforms table creation. 2026-01-17 14:44:37 -03:00
SubscriptionItem.php feat: Implement soft deletes for workspace hashtags and labels, and integrate content_type into the initial post platforms table creation. 2026-01-17 14:44:37 -03:00
User.php feat(onboarding): add goal step after persona 2026-06-25 20:49:04 -03:00
Workspace.php Structure brand voice and make generated copy platform-aware 2026-06-12 17:09:39 -03:00
WorkspaceInvite.php refactor: restructure to Actions, subdomain routes (app/api), API tokens 2026-03-29 19:24:28 -03:00
WorkspaceLabel.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
WorkspaceSignature.php chore: remove deprecated localization files 2026-05-03 15:23:25 -03:00