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

Epic/feat/admin tools2 #2410

Closed
wants to merge 4 commits into from
Closed

Epic/feat/admin tools2 #2410

wants to merge 4 commits into from

Conversation

alonp99
Copy link
Collaborator

@alonp99 alonp99 commented May 26, 2024

Summary by CodeRabbit

  • New Features

    • Introduced the ability to send welcome emails using SendGrid upon user account creation in the workflows service.
  • Bug Fixes

    • Improved logging to handle missing EMAIL_API_TOKEN by issuing a warning instead of failing silently.

alonp99 and others added 2 commits April 25, 2024 11:57
* epic/feat/admin-tools sendgrid added to endpoint

* epic/feat/admin-tools2 sendgrid changes

* epic/feat/admin-tools2 sendgrid prettier check

* epic/feat/admin-tools2 sendgrid newline

* epic/feat/admin-tools2 added logger console

* epic/feat/admin-tools2 sendgrid mail-body

* epic/feat/admin-tools2 sendgrid error handling

* epic/feat/admin-tools2 typesafe - error

* Update services/workflows-service/src/user/user.controller.internal.ts

Co-authored-by: Omri Levy <[email protected]>

* epic/feat/admin-tools2 using EMAIL_API_TOKEN

---------

Co-authored-by: Satyam-G5 <[email protected]>
Co-authored-by: Alon Peretz <[email protected]>
Co-authored-by: Omri Levy <[email protected]>
Copy link

changeset-bot bot commented May 26, 2024

⚠️ No Changeset found

Latest commit: 436d41c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented May 26, 2024

Walkthrough

The primary changes involve enhancing the workflows-service by integrating the SendGrid mailing service. This update includes adding the @sendgrid/mail package as a dependency, modifying the UserCreateDto class to support sending welcome emails, and updating user creation logic in UserControllerInternal to handle the new email-sending functionality.

Changes

File Summary
.../workflows-service/package.json Added the @sendgrid/mail package at version 8.1.3 to the dependencies.
.../workflows-service/src/user/dtos/user-create.ts Introduced CreateOptions class with sendWelcomeEmail property and updated UserCreateDto accordingly.
.../workflows-service/src/user/user.controller.internal.ts Modified UserControllerInternal constructor to include AppLoggerService and updated create method to send an email.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant UserControllerInternal
    participant UserService
    participant SendGrid API
    participant Logger

    Client->>UserControllerInternal: create(userCreateInfo, currentProjectId)
    UserControllerInternal->>UserService: createUser(userCreateInfo, currentProjectId)
    UserService-->>UserControllerInternal: userCreated
    alt sendWelcomeEmail is true
        UserControllerInternal->>SendGrid API: sendWelcomeEmail(userEmail)
        SendGrid API-->>UserControllerInternal: Email sent
        UserControllerInternal->>Logger: Log email sent success
    else sendWelcomeEmail is false
        UserControllerInternal->>Logger: Log email not sent
    end
    UserControllerInternal-->>Client: userCreatedResponse
Loading

Poem

In the realm of code, changes flow,
Enhancing services, making them glow.
Welcome emails now take flight,
Guided by SendGrid's might.
Loggers watch with silent cheer,
As user joy draws near.
CodeRabbit's touch, soft and bright,
Brings delight, in bytes of light.


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: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 387880b and 514f006.
Files selected for processing (3)
  • services/workflows-service/package.json (1 hunks)
  • services/workflows-service/src/user/dtos/user-create.ts (2 hunks)
  • services/workflows-service/src/user/user.controller.internal.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • services/workflows-service/package.json
Additional Context Used
Biome (7)
services/workflows-service/src/user/user.controller.internal.ts (7)

27-27: Decorators are not valid here.


28-28: Decorators are not valid here.


53-53: Decorators are not valid here.


54-54: Decorators are not valid here.


3-4: All these imports are only used as types.


5-6: All these imports are only used as types.


13-14: All these imports are only used as types.

Additional comments not posted (4)
services/workflows-service/src/user/dtos/user-create.ts (2)

5-14: The CreateOptions class is well-defined with appropriate API documentation and validation decorators.


68-70: The addition of the options property to UserCreateDto is well-implemented, making the sending of a welcome email configurable.

services/workflows-service/src/user/user.controller.internal.ts (2)

20-20: The addition of the logger parameter to the constructor enhances logging capabilities, aligning with best practices for error handling and diagnostics.


Line range hint 56-131: The updates to the create method, including handling the options property and integrating email sending functionality, are well-implemented. Ensure that the EMAIL_API_TOKEN is securely managed.


if (!process.env.EMAIL_API_TOKEN) {
this.logger.warn('SendGrid API key not provided. Email will not be not send ');
this.logger.log('Email:', message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing sensitive information from logs to enhance security. Logging the entire email content could expose user details.

- this.logger.log('Email:', message);
+ this.logger.log('Email sending initiated to:', message.to);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
this.logger.log('Email:', message);
this.logger.log('Email sending initiated to:', message.to);

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 514f006 and 59ca5f7.
Files selected for processing (1)
  • services/workflows-service/package.json (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/workflows-service/package.json

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 59ca5f7 and 436d41c.

Files selected for processing (1)
  • services/workflows-service/package.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • services/workflows-service/package.json

@alonp99 alonp99 closed this Jan 26, 2025
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