Skip to content
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

do email verification on project verification form through Ortto #1649

Conversation

RamRamez
Copy link
Collaborator

@RamRamez RamRamez commented Jun 24, 2024

#1512

Summary by CodeRabbit

  • New Features

    • Introduced a new email confirmation functionality via notifications.
  • Refactor

    • Replaced the mailer service with the notification adapter for sending email confirmations.
  • Environment Configuration

    • Removed deprecated DApp mailer configurations.
  • Bug Fixes

    • Made userWalletAddress optional in the notification body interface.
  • Analytics

    • Added the SEND_EMAIL_CONFIRMATION event for tracking email confirmations.

Copy link
Contributor

coderabbitai bot commented Jun 24, 2024

Walkthrough

Recent changes focus on removing DApp mailer functionality by eliminating its configurations from environment files and updating relevant code by integrating new email confirmation methods in the notification system. This change centralizes email handling, leveraging a mock and a notification interface to streamline the process.

Changes

Files Change Summary
config/example.env
config/test.env
Removed DApp mailer URL, authorization key, and mailer enable flags
src/adapters/notifications/MockNotificationAdapter.ts Added sendEmailConfirmation method to mock adapter
src/adapters/notifications/NotificationAdapterInterface.ts Added sendEmailConfirmation method to the interface
src/adapters/.../NotificationCenterAdapter.ts Added support for email confirmations and modified notification body interface
src/analytics/analytics.ts Added SEND_EMAIL_CONFIRMATION event to NOTIFICATIONS_EVENT_NAMES enum
src/resolvers/projectVerificationFormResolver.ts Replaced mailerService email confirmation with NotificationAdapter method

Sequence Diagrams

sequenceDiagram
    actor User
    participant Resolver as ProjectVerificationFormResolver
    participant AdapterFactory as AdaptersFactory
    participant NotificationAdapter as NotificationAdapter<sendEmailConfirmation>

    User->>Resolver: Submits project for verification
    Resolver->>AdapterFactory: Get NotificationAdapter
    AdapterFactory-->>Resolver: Return NotificationAdapter
    Resolver->>NotificationAdapter: Call sendEmailConfirmation with email, project, token
    NotificationAdapter-->>Resolver: Email confirmation sent
    Resolver-->>User: Project verification submitted
Loading

Poem

In the code where changes weave and spin,
DApp mailer gone, a brand-new win!
Email confirmations, sleek and clear,
In mock and notifications, we now steer.
Cheers to updates, swift and bright,
Keep our projects soaring high and light! ✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7a723ce and 804a396.

Files selected for processing (7)
  • config/example.env (1 hunks)
  • config/test.env (1 hunks)
  • src/adapters/notifications/MockNotificationAdapter.ts (1 hunks)
  • src/adapters/notifications/NotificationAdapterInterface.ts (1 hunks)
  • src/adapters/notifications/NotificationCenterAdapter.ts (4 hunks)
  • src/analytics/analytics.ts (1 hunks)
  • src/resolvers/projectVerificationFormResolver.ts (2 hunks)
Files skipped from review due to trivial changes (2)
  • config/example.env
  • src/analytics/analytics.ts
Additional context used
Gitleaks
config/test.env

16-17: Found a Stripe Access Token, posing a risk to payment processing services and sensitive financial data. (stripe-access-token)


95-96: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


96-97: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


98-99: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


99-100: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Biome
src/resolvers/projectVerificationFormResolver.ts

[error] 43-43: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 116-116: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 118-118: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 200-200: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 201-201: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 253-253: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 255-255: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 302-302: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 303-303: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

src/adapters/notifications/NotificationCenterAdapter.ts

[error] 942-948: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Additional comments not posted (5)
src/adapters/notifications/NotificationAdapterInterface.ts (1)

58-62: Approved the addition of sendEmailConfirmation method.

This addition is aligned with the PR's objective to integrate email verification using Ortto. The method signature is correctly defined and uses appropriate types, ensuring robustness and type safety.

src/adapters/notifications/MockNotificationAdapter.ts (1)

24-31: Approved the implementation of sendEmailConfirmation in MockNotificationAdapter.

The method provides a mock implementation consistent with the interface definition. It correctly logs the input parameters and resolves the promise, which is suitable for testing and development environments.

src/resolvers/projectVerificationFormResolver.ts (1)

185-189: Approved the integration of sendEmailConfirmation in projectVerificationFormResolver.

The method is correctly integrated into the resolver's projectVerificationSendEmailConfirmation mutation. It uses the correct parameters and follows the new email verification process using Ortto, as intended in the PR.

src/adapters/notifications/NotificationCenterAdapter.ts (2)

60-79: Implementation of sendEmailConfirmation method.

The sendEmailConfirmation method has been implemented to handle sending email confirmations. The method constructs a verification link using the project slug and token, and logs errors appropriately. Ensure that the callSendNotification function is robust and handles different types of errors effectively, as email sending is critical functionality.


34-34: Verify the usage of the FRONTEND_URL environment variable.

The dappUrl is derived from FRONTEND_URL. Ensure that this environment variable is correctly set in all environments (development, test, production) to prevent runtime errors.

Verification successful

Verification Successful: FRONTEND_URL Environment Variable Usage

The FRONTEND_URL environment variable is correctly set in the configuration files and used appropriately in the codebase.

  • config/test.env: FRONTEND_URL=test.giveth.io
  • config/example.env: FRONTEND_URL=test.giveth.io
  • src/adapters/notifications/NotificationCenterAdapter.ts: const dappUrl = process.env.FRONTEND_URL as string;
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the existence and non-empty value of FRONTEND_URL in environment configuration files.
fd --type file --extension env --exec grep "FRONTEND_URL=" {}

Length of output: 119



Script:

#!/bin/bash
# Search for all occurrences of FRONTEND_URL in the codebase
rg "FRONTEND_URL"

Length of output: 216


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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
Contributor

@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: 0

Outside diff range and nitpick comments (1)
src/adapters/notifications/NotificationCenterAdapter.ts (1)

Line range hint 942-948: Unnecessary else clause.

Following the static analysis hint, the else clause after an early break in a conditional block can be removed for cleaner and more efficient code.

- else {
-   // Code inside else
- }

Copy link
Collaborator

@mohammadranjbarz mohammadranjbarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @RamRamez LGTM

@RamRamez RamRamez merged commit e1542ad into staging Jun 30, 2024
5 checks passed
@RamRamez RamRamez deleted the do-email-verification-on-project-verification-form-through-Ortto branch June 30, 2024 18:49
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.

3 participants