trypost/app/Jobs
Paulo Castellano 2f4b974130 Fix X token chain breaking from over-rotation
X OAuth2 refresh tokens are single-use: each refresh rotates the pair and
invalidates the previous refresh_token, and reusing a rotated one kills the
whole family. Three things made this fragile and disconnected accounts far
more often than necessary:

- The proactive refresh job called refreshToken() directly, bypassing the
  access-token-first guard in verify() and rotating on every run.
- RefreshExpiringTokens used a 2h window on an hourly schedule — equal to the
  2h access-token lifetime — so every X account was rotated every hour even
  while its token was still valid.
- A single 4xx refresh failure disconnected the account without checking
  whether a concurrent refresh had already persisted a working token.

Changes:
- RefreshSocialToken now routes through verify() (access-token-first), so it
  only rotates when the access_token is actually invalid.
- Shrink the proactive window to 30m and run the command every 15m, so the
  window still covers the run interval but rotation happens near real expiry.
- verify() tolerates the lost-rotation race: on a 4xx refresh, reload and
  verify with a concurrently-refreshed token before marking TokenExpired.

Refs #126
2026-07-02 20:32:55 -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 Fix X token chain breaking from over-rotation 2026-07-02 20:32:55 -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