Skip to content

Option to mark cold emails as read#318

Merged
elie222 merged 1 commit intomainfrom
cold-emails-read
Jan 30, 2025
Merged

Option to mark cold emails as read#318
elie222 merged 1 commit intomainfrom
cold-emails-read

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Jan 30, 2025

Summary by CodeRabbit

  • New Features

    • Added a new cold email blocking option: Archive, Mark as Read, and Label
    • Enhanced cold email settings with more granular control
  • Improvements

    • Refined descriptions for existing cold email blocking options
    • Updated email processing logic to support new setting
  • Technical Updates

    • Added new enum value for cold email settings
    • Enforced unique account constraint for users

@vercel
Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview Jan 30, 2025 10:15pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

This pull request introduces a new cold email blocking option ARCHIVE_AND_READ_AND_LABEL to the email management system. The change spans multiple files, including the frontend settings component, API validation, database schema, and email processing utility. The new option allows users to automatically archive cold emails, mark them as read, and apply a label, providing more granular control over handling unwanted emails.

Changes

File Change Summary
apps/web/app/(app)/cold-email-blocker/ColdEmailSettings.tsx Added new option ARCHIVE_AND_READ_AND_LABEL with description
apps/web/app/api/user/settings/cold-email/validation.ts Added enum value for new cold email setting
apps/web/prisma/migrations/20250130215802_read_cold_emails/migration.sql Updated PostgreSQL enum type with new value
apps/web/prisma/schema.prisma Added ARCHIVE_AND_READ_AND_LABEL to ColdEmailSetting enum, added @unique to userId in Account model
apps/web/utils/cold-email/is-cold-email.ts Updated email blocking logic to handle new setting, added shouldMarkRead variable

Sequence Diagram

sequenceDiagram
    participant User
    participant ColdEmailBlocker
    participant EmailService
    
    User->>ColdEmailBlocker: Select ARCHIVE_AND_READ_AND_LABEL
    ColdEmailBlocker->>EmailService: Process Cold Email
    EmailService-->>EmailService: Archive Email
    EmailService-->>EmailService: Mark Email as Read
    EmailService-->>EmailService: Apply Cold Email Label
Loading

Possibly related PRs

Poem

🐰 A rabbit's tale of email might,
Cold messages now flee from sight
Archived, read, and labeled clear
No more spam to cause us fear!
Hop along, email control is here! 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 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 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 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. (Beta)
  • @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.

CodeRabbit Configuration 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

🧹 Nitpick comments (1)
apps/web/utils/cold-email/is-cold-email.ts (1)

176-187: Consider enhancing error handling for missing label ID.

While the code logs an error when the label ID is missing, it continues execution which might lead to unexpected behavior. Consider either:

  1. Throwing an error to prevent processing with missing label
  2. Adding a warning log when attempting to add a null label ID
 const addLabelIds: string[] = [];
-if (coldEmailLabel?.id) addLabelIds.push(coldEmailLabel.id);
+if (coldEmailLabel?.id) {
+  addLabelIds.push(coldEmailLabel.id);
+} else {
+  logger.warn("Skipping label addition due to missing label ID", {
+    userId: user.id,
+    messageId: email.messageId
+  });
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ef78f3 and e84ac91.

📒 Files selected for processing (5)
  • apps/web/app/(app)/cold-email-blocker/ColdEmailSettings.tsx (1 hunks)
  • apps/web/app/api/user/settings/cold-email/validation.ts (1 hunks)
  • apps/web/prisma/migrations/20250130215802_read_cold_emails/migration.sql (1 hunks)
  • apps/web/prisma/schema.prisma (1 hunks)
  • apps/web/utils/cold-email/is-cold-email.ts (2 hunks)
🔇 Additional comments (7)
apps/web/app/api/user/settings/cold-email/validation.ts (1)

11-11: LGTM! Schema updated correctly.

The new enum value is properly added to the validation schema while maintaining backward compatibility.

apps/web/app/(app)/cold-email-blocker/ColdEmailSettings.tsx (1)

88-92: LGTM! UI changes are clear and well-organized.

The new option is added with a clear label and description. The descriptions for existing options have been simplified for better clarity. The ordering of options from most to least aggressive action is logical.

Also applies to: 96-96, 101-101

apps/web/utils/cold-email/is-cold-email.ts (2)

158-159: LGTM! New setting correctly integrated.

The condition check properly includes the new setting alongside existing options.


170-181: LGTM! Clear flag management.

The shouldArchive and shouldMarkRead flags clearly separate the different actions, making the code more maintainable.

apps/web/prisma/migrations/20250130215802_read_cold_emails/migration.sql (1)

1-2: LGTM! Migration is safe and follows best practices.

The enum value addition is a safe operation that won't cause any disruption during deployment.

apps/web/prisma/schema.prisma (2)

415-415: LGTM! The new enum value follows the existing pattern.

The addition of ARCHIVE_AND_READ_AND_LABEL logically extends the current functionality and aligns with the PR objective.

Let's verify the related changes:

✅ Verification successful

✓ Verified: New enum value is properly implemented across the codebase

The ARCHIVE_AND_READ_AND_LABEL option is fully integrated with:

  • Database migration
  • Frontend settings UI
  • Backend email processing logic
  • Input validation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify related changes for the new enum value
# Note: This helps ensure all necessary changes are in place

echo "Checking for migration file..."
fd -g "*_read_cold_emails.sql" -g "*cold*email*.sql"

echo "Checking for enum usage in code..."
rg "ARCHIVE_AND_READ_AND_LABEL|ColdEmailSetting" -t ts -t tsx

echo "Checking for email processing logic updates..."
rg "handleColdEmail|processColdEmail" -t ts

Length of output: 549


Script:

#!/bin/bash
# Search for migration files
echo "Checking for migration files..."
fd -e sql

echo "Checking for enum usage in code..."
rg --type-add 'ts:*.{ts,tsx}' -t ts 'ARCHIVE_AND_READ_AND_LABEL|ColdEmailSetting'

echo "Checking for email processing logic..."
rg --type-add 'ts:*.{ts,tsx}' -t ts 'handleColdEmail|processColdEmail|ColdEmailSetting\.ARCHIVE_AND_READ_AND_LABEL'

echo "Checking for settings components..."
rg --type-add 'ts:*.{ts,tsx}' -t ts 'ColdEmailSetting.*ARCHIVE_AND_READ_AND_LABEL' -A 2

Length of output: 12575


Line range hint 19-19: Consider separating the Account model changes into a different PR.

The addition of @unique constraint to userId seems unrelated to the PR's objective of marking cold emails as read. This change could have data migration implications and might break existing data if users have multiple accounts.

Let's verify if there are any users with multiple accounts:

@elie222 elie222 merged commit 6e3f6a0 into main Jan 30, 2025
4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request May 25, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 3, 2025
@elie222 elie222 deleted the cold-emails-read branch December 18, 2025 23:00
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.

1 participant

Comments