trypost/app/Jobs
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
..
Ai refactor(ai): introduce GeneratorFormat enum and drop stringly-typed format 2026-06-18 11:11:23 -03:00
Automation Harden automations module: full-post generation, reliable runs, editor UX 2026-06-10 20:45:01 -03:00
PostHog feat(billing): attach persona to conversion tracking and polish annual banner 2026-06-22 12:32:03 -03:00
PublishPost.php fix: withoutOverlapping on schedules, publisher token refresh lock, PublishPost tries:1, TokenExpired allows publish, API validation scoping 2026-04-01 12:49:01 -03:00
PublishToSocialPlatform.php refactor(social): trim verbose comments + harden X chunked upload from review 2026-06-28 20:37:04 -03:00
RefreshSocialToken.php Keep Instagram/Threads tokens extended while still valid 2026-07-03 09:18:45 -03:00
SendNotification.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
VerifyWorkspaceConnections.php fix(social): move Mastodon default instance to config + cleanup 2026-05-19 08:27:46 -03:00