8000 feat: plan based email logoUrl by ChiragAgg5k · Pull Request #9745 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 5 commits into from
May 15, 2025
Merged

feat: plan based email logoUrl #9745

merged 5 commits into from
May 15, 2025

Conversation

ChiragAgg5k
Copy link
Member
@ChiragAgg5k ChiragAgg5k commented May 12, 2025

What does this PR do?

adds plan based logoUrl etc., along with APP_EMAIL_LOGO_URL as a fallback etc.

Test Plan

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Summary by CodeRabbit

  • New Features

    • Email notifications now support dynamic branding with customizable logos, social media links, and legal page URLs based on project or plan settings.
    • Enhanced email templates and alerts include dynamic placeholders for logos, Twitter, Discord, GitHub, Terms, and Privacy URLs to improve branding consistency.
  • Chores

    • Added new constants for default email logo, social media, and legal URLs.
    • Updated email template and notification systems to use configurable URLs instead of hardcoded links.
    • Registered a new resource for plan data to support dynamic email content customization.

Copy link
coderabbitai bot commented May 12, 2025

Walkthrough

The changes replace multiple hardcoded URLs in the email template with dynamic placeholder variables. A new plan dependency is injected into relevant controllers and worker classes to provide these URLs dynamically, defaulting to new constants if not specified. Additionally, a new plan resource is registered in the server returning an empty array.

Changes

File(s) Change Summary
app/config/locale/templates/email-base-styled.tpl Replaced hardcoded URLs for logo, social media links (Twitter, Discord, GitHub), and footer links (Terms, Privacy) with corresponding placeholders.
app/controllers/api/projects.php Injected plan dependency into SMTP test endpoint; sets multiple template parameters (logoUrl, social links, terms, privacy URLs) from plan or constants.
app/init/constants.php Added constants for default URLs: APP_EMAIL_LOGO_URL, APP_EMAIL_ACCENT_COLOR, APP_EMAIL_TERMS_URL, APP_EMAIL_PRIVACY_URL, and APP_SOCIAL_GITHUB_APPWRITE.
src/Appwrite/Platform/Workers/Certificates.php Injected plan dependency; updated method signatures to accept and propagate plan; set multiple template parameters for error notification emails.
src/Appwrite/Platform/Workers/Webhooks.php Injected plan dependency; updated method signatures to accept and propagate plan; set multiple template parameters for webhook failure email alerts.
app/worker.php Added new plan resource returning an empty array regardless of input.

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
Loading

Poem

🐇
A logo hops into each mail,
No longer fixed upon the trail.
With {{logoUrl}} and links anew,
Social hops and terms in view.
Constants set, dependencies spun—
Dynamic emails, fresh as sun!
🌸📧🐰

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit 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.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit 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 Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
github-actions bot commented May 12, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH
libxml2 2.12.7-r0 CVE-2025-32414 HIGH
libxml2 2.12.7-r0 CVE-2025-32415 HIGH
sqlite-libs 3.45.3-r1 CVE-2025-29087 HIGH
xz 5.6.2-r0 CVE-2025-31115 HIGH
xz-libs 5.6.2-r0 CVE-2025-31115 HIGH
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f8fe13 and a802a78.

📒 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

Copy link
github-actions bot commented May 12, 2025

✨ Benchmark results

  • Requests per second: 955
  • Requests with 200 status code: 171,968
  • P99 latency: 0.190792413

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 955 1,350
200 171,968 243,001
P99 0.190792413 0.135676888

Copy link
@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between a2686b4 and fe767e9.

📒 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

Comment on lines +366 to +368
Server::setResource('plan', function (array $plan = []) {
return [];
});
Copy link

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.

@eldadfux eldadfux merged commit 919c427 into 1.7.x May 15, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0