trypost/app
Paulo Castellano 5f7768ca3a fix: apply code review — enforce quota server-side, project conventions
Critical fixes:
- Quota enforcement regressed when the regex flow was replaced with
  tools. The LLM was trusted to respect [Session state] quota hints,
  which is vulnerable to prompt injection / hallucination. Each tool
  now checks Pennant feature limits at the top of handle() and returns
  a short quota-exhausted string instead of calling the provider.
  Audio shares the video quota (there is no AiAudioLimit by design).
- N+1 on aiMessages: combined the two separate ->get() scans that
  produced imagesInThread and videosInThread into a single query.
- postPlatforms lazy load: controller now loadMissing('postPlatforms')
  before constructing SocialMediaAssistant, which accesses the relation
  in activePlatformRules().

Project conventions:
- \RuntimeException and \Throwable are now imported at the top of the
  controller instead of inlined per CLAUDE.md.
- Tool handle() methods use data_get($request, 'prompt') instead of
  direct array access, matching the data_get convention for service
  classes.
- enrichContent() pluralizes attachment types via Str::plural so
  '2 images' reads naturally instead of '2 image'.

Tests:
- Added Storage::fake('public') in tool tests so runs don't pollute
  the local disk with fake-generated files.
- Restored quota enforcement coverage (deleted when the flow changed)
  as three new tests — one per tool — that fill the monthly bucket
  and assert the tool refuses and nothing is generated.
- Removed inline \App\ references in tests in favor of imports.
2026-04-16 10:22:55 -03:00
..
Actions feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Ai fix: apply code review — enforce quota server-side, project conventions 2026-04-16 10:22:55 -03:00
Broadcasting feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
Concerns refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
Console/Commands fix: RecoverStuckPosts also recovers platforms stuck in Pending status 2026-04-01 13:12:55 -03:00
DataTransferObjects feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Enums feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
Events feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
Exceptions fix: Facebook/Instagram/Threads OAuthException type incorrectly treated as token error — now only code 190 triggers TokenExpiredException 2026-04-01 14:33:26 -03:00
Features feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Helpers fix: correct Upload.php filename case for Linux CI 2026-03-31 12:01:48 -03:00
Http fix: apply code review — enforce quota server-side, project conventions 2026-04-16 10:22:55 -03:00
Jobs feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Listeners feat: redesign billing, onboarding, sidebar, and settings architecture 2026-04-15 00:33:38 -03:00
Mail feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Mcp feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Models feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
Policies feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Providers feat: add platform rules for all 12 supported social networks 2026-04-16 10:03:14 -03:00
Rules refactor: restructure to Actions, subdomain routes (app/api), API tokens 2026-03-29 19:24:28 -03:00
Services refactor: migrate PostAssistantController to SDK Agent + tools 2026-04-16 09:59:10 -03:00
Socialite refactor: code review fixes — policies, enums, data_get, tests 2026-03-31 00:40:18 -03:00