Skip to content

Comments

User can delete mails permanently from bin #669

Closed
Adarsh9977 wants to merge 4 commits intoMail-0:mainfrom
Adarsh9977:zero/new-feature
Closed

User can delete mails permanently from bin #669
Adarsh9977 wants to merge 4 commits intoMail-0:mainfrom
Adarsh9977:zero/new-feature

Conversation

@Adarsh9977
Copy link
Contributor

@Adarsh9977 Adarsh9977 commented Apr 15, 2025

Description

User now able to delete his mails permanently from bin


Type of Change

Please delete options that are not relevant.

  • ✨ New feature (non-breaking change which adds functionality)
  • 🎨 UI/UX improvement
  • 🔒 Security enhancement
  • ⚡ Performance improvement

Present workflow

  • user not able to delete his mails from bin
Screen.Recording.2025-04-15.at.5.12.38.PM.mov

Upgraded workflow

  • user now able to delete his mails permanently from bin
Screen.Recording.2025-04-15.at.5.14.13.PM.mov

By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

Summary by CodeRabbit

  • New Features
    • Added the ability to permanently delete email threads from the Bin via a new context menu option.
  • Improvements
    • Enhanced Google authentication by expanding OAuth permissions for broader mail access.
  • Localization
    • Introduced new English status messages and labels related to mail deletion actions for improved user feedback.

@vercel
Copy link

vercel bot commented Apr 15, 2025

@Adarsh9977 is attempting to deploy a commit to the Zero Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 15, 2025

## Walkthrough

This update introduces a new capability for permanently deleting email threads from the bin in the mail application. It adds an asynchronous `deleteThread` action, integrates a "Delete from Bin" menu option within the thread context menu (visible when in the bin folder), and provides user feedback through localized toast notifications. The OAuth scopes for the Google authentication provider are expanded to enable broader mail access. New English localization strings are added to support the new deletion-related actions and messages.

## Changes

| File(s)                                      | Change Summary                                                                                       |
|----------------------------------------------|----------------------------------------------------------------------------------------------------|
| apps/mail/actions/mail.ts                     | Added `deleteThread` async function to delete an email thread by ID with error handling.           |
| apps/mail/components/context/thread-context.tsx | Added `handleDelete` handler and integrated "Delete from Bin" menu option into `ThreadContextMenu`.|
| apps/mail/lib/auth-providers.ts               | Expanded Google OAuth scopes to include `https://mail.google.com` for full mail access.            |
| apps/mail/locales/en.json                      | Added localization strings for mail deletion actions and "Delete from Bin" menu label.             |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant UI (ThreadContextMenu)
    participant Actions (deleteThread)
    participant Driver
    participant Toast

    User->>UI (ThreadContextMenu): Selects "Delete from Bin"
    UI (ThreadContextMenu)->>Toast: Show "Deleting mail..." (loading)
    UI (ThreadContextMenu)->>Actions (deleteThread): Call with threadId
    Actions (deleteThread)->>Driver: delete(threadId)
    Driver-->>Actions (deleteThread): Success/Failure
    Actions (deleteThread)-->>UI (ThreadContextMenu): Return result
    UI (ThreadContextMenu)->>Toast: Show "Mail deleted" or "Failed to delete mail"
    UI (ThreadContextMenu)->>UI (ThreadContextMenu): Refresh data (mutate)

Possibly related PRs

  • keyboard navigation #521: This PR removes the ThreadContextMenu component that is modified here, indicating a direct impact on the same component but with opposite changes.

Suggested reviewers

  • needleXO

Poem

In the bin, a thread once lay,
With a click, it's swept away.
Toasts appear—"Deleted!"—cheer,
New scopes ensure all mail is clear.
Strings now guide what users see,
Hopping forward, code runs free!
🐇✨


<!-- walkthrough_end -->

<!-- announcements_start -->

> [!TIP]
> <details>
> <summary>⚡💬 Agentic Chat (Pro Plan, General Availability)</summary>
> 
> - We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
> 
> </details>

<!-- announcements_end -->

---

<details>
<summary>📜 Recent review details</summary>

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

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between c6fead4a6594cabe7487cdc92d9edaa20650d560 and abfeca0371f64fabe9f19edf8deb1e9777b7f431.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `apps/mail/components/context/thread-context.tsx` (3 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* apps/mail/components/context/thread-context.tsx

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAVURKRkxIJUiaSGZtL2RuSkzyDAj5ADMKFkg1DAAaaPtsAWZ1Gno5SGwEvgBBWmdEWABOfoB2IfRkW0gMRwFEgDZZ/qqUQrLabAZpdEmSAHdIYpJqbH90H3wd+AwiNo7kAh48zHYveVSSdJJM+Gz9suYw2AeSoaawUeD4Pj3XAIZDYbg9GhLdqUZA7SgebAYFSRML4FIkNIeL4/UrlaFAy4g9yMWCYUjLBhebBKZCxACSAHpYgANFDMXj4KRsQqIJYJBjHdTyMi0jAbYW4UXoDD0XIUYoQ/IbPkCoXsRBUwFteHUKI7CEAa2KXnOkDI2M2yIodzx/mYgo8nyyOUeBSKvzJRsqSxlmAYl2u5IyWWjWNICrtAA81fAyBtDR4JpdGczNhIkNg0L5/Ad/HLNkp3RhELgqOIrgCPLwSPn8O1lfQ4UQqEp6OaKFabTsDTAjUwVvABHhwVhUJklG0VYkowKRGIAOTILzwDbVjw0CjMA1GfTGcBQMj0fDFHAEYhkZTNBSsdhcXj8YSicRSGTyJhKKhVHULQdFPEwoDgVBUGSNA8EIUhyDrKImBfQouCoPYHCcFwKj/RRlCAzRtF0MBDDPUwDDQbhuEQDliQ5NAxBnWjiQ0RUOAMaIuIMCxIE6Nl70Q016CwzIcOvGk6WkIxOm2PY0EQWQ5VgMoMDbZBikxJj8CwAADN4aDgfw0FoXSUGQEzeyWHYEAYWB0AYDZuEVZUPzXUILmhLZEAjHEazBBsBTVXB5F0+BTJBNlQhtIg7iNaFjPoNkABFcQqDwDLoJZ/FrVMf0bBzvwysEpAoJZMHoBgix+KNaBKyhN0gfSCX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QgSSB2/TxiBvEoMqiwbXimmClVF74G7TDE+1IKsCUzfb0VRYWliiLuL7M3g9k54l8W3OJatslw+UAfMKbSoX5znhS8sZpTpJYOLtpLAehIZw8AHTYsi7rRAABufgGAstXssxJaNr2bFyMTg2C0JBzFMK70yM+DXPvfdmnN442oZY/prYNsi4FLZXj2nBAdq2tevj8GgTCw6d5YP/ARNQRFQKkQMMflCjRcAAH1wqIB/38HzF2DoB/wRycxIiP3PEgFmAEDQH6AAA4GAEC0AABWAAJgEAAGYSAECZgAAWAABkwNmAYHQMIIAEYhhZg0Bih+h8CsChgEDaBEVyD0DICP9oCGBZgDgTJ8C0BZhUD6CqoZghh8CEChgGBaAGB+h0DaB+g6A0A0ByDBDCDaBUDZhCCODj8VADgqpCDGCKDihZh8DEUZh+higKCFCWDmCSABAKCSBhgRgBAhhigGCKCODOCIAtd1A/9aAACgDUw0RaAf9vd9AgA -->

<!-- internal state end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=Mail-0/Zero&utm_content=669):

- 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](https://docs.coderabbit.ai/finishing-touches/docstrings) for 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.

### 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f5f60f and 6ba98c8.

📒 Files selected for processing (4)
  • apps/mail/actions/mail.ts (1 hunks)
  • apps/mail/components/context/thread-context.tsx (3 hunks)
  • apps/mail/lib/auth-providers.ts (1 hunks)
  • apps/mail/locales/en.json (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/mail/components/context/thread-context.tsx (1)
apps/mail/actions/mail.ts (1)
  • deleteThread (158-169)
🔇 Additional comments (5)
apps/mail/lib/auth-providers.ts (1)

51-51:

Details

❌ Incorrect review comment

Expanded OAuth scope adds broader Gmail access

The addition of 'https://mail.google.com' scope significantly increases the permissions requested from users. This scope grants full access to Gmail, which is more expansive than needed for just deleting emails from the bin.

Consider evaluating whether a more limited scope could achieve the same goal:


🌐 Web query:

What is the minimum OAuth scope needed for Gmail API to delete messages permanently?

💡 Result:

To delete Gmail messages permanently using the Gmail API, the required OAuth 2.0 scope is https://mail.google.com/, which provides full access to Gmail accounts, including the ability to immediately and permanently delete messages, bypassing the Trash folder[1][6][9]. This is a restricted scope, so it requires additional verification from Google if used in a production application.

Citations:


Clarification on Gmail OAuth Scope Usage

After verifying the API requirements, the web search confirms that to permanently delete Gmail messages (i.e., bypass the Trash), the minimum OAuth 2.0 scope required is indeed https://mail.google.com/. Although this scope grants full access to Gmail, it is necessary for that specific deletion functionality. In other words, the current code at line 51 is correct for its intended purpose, and no reduction in permissions is possible if permanent deletion is required.

Likely an incorrect or invalid review comment.

apps/mail/locales/en.json (2)

22-24: LGTM! Appropriate localization for mail deletion actions.

The added status messages for deleting mail are clear and consistent with the existing localization pattern.


251-251: LGTM! Clear menu item label for bin deletion.

The "Delete from Bin" label clearly communicates the action to users.

apps/mail/actions/mail.ts (1)

158-169:

Details

✅ Verification successful

Verify deletion implementation in mail driver

The deleteThread function is well-structured and follows the pattern of other functions in this file. However, we should verify that the mail driver's delete method is properly implemented to permanently delete emails rather than just moving them to the bin.


🏁 Script executed:

#!/bin/bash
# Check for delete implementation in mail drivers
rg -A 5 "delete\(.*\)" --glob 'apps/mail/**/*.ts'

Length of output: 2803


Action: Confirmed permanent deletion implementation

The mail driver's deletion logic was verified. In particular, the implementation in apps/mail/app/api/driver/google.ts uses the Gmail API’s users.messages.delete method—which permanently deletes the message—while the type declarations in apps/mail/app/api/driver/types.ts properly define the deletion interface. No changes are required in the deleteThread function in apps/mail/actions/mail.ts.

apps/mail/components/context/thread-context.tsx (1)

38-38: LGTM! Appropriate import of the deleteThread action.

The new import adds the required functionality without unnecessary changes.

@Adarsh9977 Adarsh9977 closed this Apr 15, 2025
@Adarsh9977 Adarsh9977 reopened this Apr 15, 2025
@Adarsh9977 Adarsh9977 closed this Apr 15, 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.

1 participant