Set project on queueForMails for span log context#11337
Conversation
The Mails worker span logs were missing project.id, project.sequence, project.region, and project.database because setProject was never called on queueForMails. This adds setProject in the shared API controller and in workers (Webhooks, Migrations) that trigger mails. Also injects project into the Mails worker action.
📝 WalkthroughWalkthroughThis pull request propagates project context through the mail queue system. The Mails worker is extended to accept a Document project parameter in its constructor and action method. The mail queue is automatically assigned the project context during initialization in the API controller. Additionally, project context is passed to the mail queue when queuing email alerts in both the Migrations worker (for CSV export notifications) and the Webhooks worker (for email alerts). Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes SummaryFour files are modified to establish a consistent pattern of project context propagation:
The changes establish consistent project association across mail queue entry points, though verification is needed to ensure all call sites align with the updated method signature and that the dependency injection is properly configured. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Appwrite/Platform/Workers/Mails.php (1)
50-58: Docblock is missing the new$projectparameter.The
@paramlist documentsMessage,Registry, andLogbut omits the newly addedDocument $project.📝 Proposed fix
/** * `@param` Message $message + * `@param` Document $project * `@param` Registry $register * `@param` Log $log * `@throws` \PHPMailer\PHPMailer\Exception * `@return` void * `@throws` Exception */
✨ Benchmark results
⚡ Benchmark Comparison
|
Summary
$queueForMails->setProject($project)in the shared API controller alongside other queue auto-set project callssetProject($project)in Webhooks and Migrations workers before triggering mailsprojectinto the Mails worker action so the framework can resolve project context from the queue payloadThis fixes span logs for the Mails worker showing empty
project.id, nullproject.sequence, andunknownforproject.region/project.database.Test plan
project.id,project.sequence,project.region,project.database