-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat: plan based email logoUrl #9745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes replace multiple hardcoded URLs in the email template with dynamic placeholder variables. A new Changes
Sequence Diagram(s)sequenceDiagram
participant Controller/Worker
participant Plan
participant EmailTemplate
Controller/Worker->>Plan: Retrieve URLs (logoUrl, twitterUrl, discordUrl, githubUrl, termsUrl, privacyUrl)
alt URLs present in plan
Controller/Worker->>EmailTemplate: Set placeholders with plan URLs
else
Controller/Worker->>EmailTemplate: Set placeholders with default constants
end
EmailTemplate-->>Controller/Worker: Render email with dynamic URLs
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
app/config/locale/templates/email-base-styled.tpl
(1 hunks)app/controllers/api/projects.php
(2 hunks)app/init/constants.php
(1 hunks)src/Appwrite/Platform/Workers/Certificates.php
(8 hunks)src/Appwrite/Platform/Workers/Webhooks.php
(7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (15)
- GitHub Check: Benchmark
- GitHub Check: E2E Service Test (Storage)
- GitHub Check: E2E Service Test (Proxy)
- GitHub Check: E2E Service Test (Health)
- GitHub Check: E2E Service Test (GraphQL)
- GitHub Check: E2E Service Test (Migrations)
- GitHub Check: E2E Service Test (Tokens)
- GitHub Check: E2E Service Test (Sites)
- GitHub Check: E2E Service Test (Locale)
- GitHub Check: E2E Service Test (FunctionsSchedule)
- GitHub Check: E2E Service Test (Databases)
- GitHub Check: E2E Service Test (Messaging)
- GitHub Check: E2E Service Test (Account)
- GitHub Check: E2E Service Test (Functions)
- GitHub Check: E2E General Test
🔇 Additional comments (17)
app/init/constants.php (1)
9-9
: Addition of new email logo URL constant is well-implemented.The new
APP_EMAIL_LOGO_URL
constant provides a consistent default for email branding when a custom logo URL is not specified in the plan.app/config/locale/templates/email-base-styled.tpl (1)
129-129
: Dynamic logo URL implementation looks good.Replacing the hardcoded image source with the
{{logoUrl}}
template variable enables dynamic branding in emails based on the plan configuration.app/controllers/api/projects.php (2)
2142-2143
: Properly injected plan dependency for SMTP test emails.The plan dependency is correctly injected and added to the function signature, following the established pattern in the codebase.
2156-2157
: Good implementation of dynamic logo URL with fallback.The code correctly sets the
{{logoUrl}}
template parameter from the plan with a proper fallback to the constant if not available.src/Appwrite/Platform/Workers/Webhooks.php (7)
40-40
: Plan dependency properly injected in Webhooks worker.The plan dependency is correctly injected into the Webhooks worker class.
51-55
: Action method signature properly updated.The action method signature is correctly updated to include the plan parameter with proper type hinting.
74-74
: Plan parameter correctly passed to execute method.The plan parameter is correctly forwarded to the execute method when processing webhooks.
91-94
: Execute method signature properly updated.The execute method signature is correctly updated to include the plan parameter with proper documentation.
170-170
: Plan parameter correctly passed to sendEmailAlert method.The plan parameter is correctly forwarded to the sendEmailAlert method when handling webhook failures.
205-208
: SendEmailAlert method signature properly updated.The sendEmailAlert method signature is correctly updated to include the plan parameter with proper documentation.
232-232
: Dynamic logo URL properly implemented in webhook failure emails.The code correctly sets the
{{logoUrl}}
template parameter from the plan with a proper fallback to the constant if not available.src/Appwrite/Platform/Workers/Certificates.php (6)
57-57
: Correctly added plan dependency to the worker class.The plan dependency is properly injected following the existing dependency injection pattern.
84-85
: Method signature correctly updated to include plan parameter.The method signature is properly updated to include the new plan parameter, which will be used for email templates.
99-99
: Plan parameter correctly forwarded to execute method.The plan parameter is properly passed from the action method to the execute method.
111-111
: Execute method signature properly updated with plan parameter.The execute method is correctly updated to include the plan parameter documentation and implementation with a sensible default empty array value.
Also applies to: 126-127
209-209
: Plan parameter correctly forwarded to notifyError method.The plan parameter is properly passed from the execute method to the notifyError method.
349-349
: NotifyError method signature properly updated.The notifyError method is correctly updated to include the plan parameter.
Also applies to: 353-353
✨ Benchmark results
⚡ Benchmark Comparison
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (6)
app/config/locale/templates/email-base-styled.tpl
(6 hunks)app/controllers/api/projects.php
(2 hunks)app/init/constants.php
(2 hunks)app/worker.php
(1 hunks)src/Appwrite/Platform/Workers/Certificates.php
(8 hunks)src/Appwrite/Platform/Workers/Webhooks.php
(7 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- src/Appwrite/Platform/Workers/Webhooks.php
- app/init/constants.php
- app/config/locale/templates/email-base-styled.tpl
- app/controllers/api/projects.php
- src/Appwrite/Platform/Workers/Certificates.php
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: scan
Server::setResource('plan', function (array $plan = []) { | ||
return []; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Validate the plan resource implementation.
The plan
resource is added as a new dependency that always returns an empty array, regardless of the input parameter. This implementation seems to be a placeholder, but it could cause issues if components expect certain keys (like logoUrl
) to be present.
Let's verify how this empty array is used:
I recommend enhancing the implementation to include the expected fallback behavior:
-Server::setResource('plan', function (array $plan = []) {
- return [];
-});
+Server::setResource('plan', function (array $plan = []) {
+ // Return plan with default values when keys are not provided
+ return [
+ 'logoUrl' => $plan['logoUrl'] ?? APP_EMAIL_LOGO_URL,
+ 'accentColor' => $plan['accentColor'] ?? APP_EMAIL_ACCENT_COLOR,
+ 'twitterUrl' => $plan['twitterUrl'] ?? APP_SOCIAL_TWITTER_URL,
+ 'discordUrl' => $plan['discordUrl'] ?? APP_SOCIAL_DISCORD_URL,
+ 'githubUrl' => $plan['githubUrl'] ?? APP_SOCIAL_GITHUB_URL,
+ 'termsUrl' => $plan['termsUrl'] ?? APP_URL_TERMS,
+ 'privacyUrl' => $plan['privacyUrl'] ?? APP_URL_PRIVACY,
+ ];
+});
🏁 Script executed:
#!/bin/bash
# Check where the plan resource is referenced in the codebase
rg -A 3 -B 3 "plan" --type php | grep -v "Server::setResource('plan'"
Length of output: 49375
Implement real plan logic in the plan resource callbacks
The current plan
resource in both app/worker.php
and app/init/resources.php
unconditionally returns an empty array, discarding any plan data carried in the project document. This effectively disables all plan-based feature flags and limits (such as runtimeSpecifications
, fileSize
, imageTransformations
, databasesBatchSize
, etc.) and will lead to unintended access/bypass of paid-plan restrictions.
Please update both callbacks to merge the incoming $plan
payload with sensible defaults. For example:
--- a/app/worker.php
+++ b/app/worker.php
@@ -363,7 +363,19 @@
Server::setResource('plan', function (array $plan = []) {
- return [];
+ // Merge provided plan data with defaults
+ return array_merge([
+ 'logoUrl' => APP_EMAIL_LOGO_URL,
+ 'accentColor' => APP_EMAIL_ACCENT_COLOR,
+ 'twitterUrl' => APP_SOCIAL_TWITTER_URL,
+ 'discordUrl' => APP_SOCIAL_DISCORD_URL,
+ 'githubUrl' => APP_SOCIAL_GITHUB_URL,
+ 'termsUrl' => APP_EMAIL_TERMS_URL,
+ 'privacyUrl' => APP_EMAIL_PRIVACY_URL,
+ // add other plan defaults here (e.g. 'fileSize' => APP_STORAGE_LIMIT, 'authPhone' => default, etc.)
+ ], $plan);
});
--- a/app/init/resources.php
+++ b/app/init/resources.php
@@ -10,7 +10,19 @@
App::setResource('plan', function (array $plan = []) {
- return [];
+ // Merge provided plan data with defaults
+ return array_merge([
+ 'logoUrl' => APP_EMAIL_LOGO_URL,
+ 'accentColor' => APP_EMAIL_ACCENT_COLOR,
+ 'twitterUrl' => APP_SOCIAL_TWITTER_URL,
+ 'discordUrl' => APP_SOCIAL_DISCORD_URL,
+ 'githubUrl' => APP_SOCIAL_GITHUB_URL,
+ 'termsUrl' => APP_EMAIL_TERMS_URL,
+ 'privacyUrl' => APP_EMAIL_PRIVACY_URL,
+ // add other plan defaults here
+ ], $plan);
});
• Locations needing updates:
app/worker.php
app/init/resources.php
Optionally factor the defaults into a shared config/constant to DRY up the two callbacks.
🤖 Prompt for AI Agents
In app/worker.php around lines 366 to 368, the plan resource callback currently
returns an empty array, which disables all plan-based feature flags and limits.
Update this callback to merge the incoming $plan array with a set of sensible
default values that include expected keys like logoUrl, runtimeSpecifications,
fileSize, imageTransformations, and databasesBatchSize. This will ensure the
plan resource provides meaningful data and enforces paid-plan restrictions
correctly. Consider defining these defaults in a shared config or constant to
reuse in app/init/resources.php for consistency.
What does this PR do?
adds plan based
logoUrl
etc., along withAPP_EMAIL_LOGO_URL
as a fallback etc.Test Plan
Related PRs and Issues
Checklist
Summary by CodeRabbit
New Features
Chores