dreamhunter2333 / cloudflare_temp_email

CloudFlare free temp domain email å…č“¹ę”¶å‘ äø“ę—¶åŸŸåé‚®ē®± ę”ÆęŒé™„ä»¶ IMAP SMTP TelegramBot
https://mail.awsl.uk
MIT License
2.15k stars 801 forks source link

fix: bugs && release v0.7.4 #432

Closed dreamhunter2333 closed 1 month ago

dreamhunter2333 commented 1 month ago

User description

430

431


PR Type

Bug fix, Enhancement


Description


Changes walkthrough šŸ“

Relevant files
Enhancement
common.ts
Enhance name validation and add block list check                 

worker/src/common.ts
  • Added checkNameBlockList function to validate names against a block
    list.
  • Modified newAddress function to include checkNameBlockList and
    improved name validation.
  • Imported getJsonSetting from utils.
  • +21/-3   
    Bug fix
    utils.ts
    Fix default domains configuration handling                             

    worker/src/utils.ts
  • Updated getDefaultDomains to handle undefined or null DEFAULT_DOMAINS.
  • Ensured fallback to getDomains if DEFAULT_DOMAINS is not set.
  • +4/-2     
    Documentation
    CHANGELOG.md
    Update changelog for version 0.7.4                                             

    CHANGELOG.md
  • Updated changelog for version 0.7.4.
  • Documented fixes for name validation and default domains
    configuration.
  • +3/-1     

    šŸ’” PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    github-actions[bot] commented 1 month ago

    PR Reviewer Guide šŸ”

    ā±ļø Estimated effort to review: 2 šŸ”µšŸ”µāšŖāšŖāšŖ
    šŸ”’ No security concerns identified
    āš” Key issues to review

    Error Handling
    The `checkNameBlockList` function catches and logs errors but does not rethrow them or handle them in a way that informs the caller of the failure. This could lead to silent failures where the caller assumes the name is valid even if an error occurred during the block list check.
    github-actions[bot] commented 1 month ago

    PR Code Suggestions āœØ

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add await to the checkNameBlockList function call to ensure it completes before proceeding ___ **To ensure that the checkNameBlockList function is properly awaited, add the await
    keyword before calling it. This will ensure that the function completes before
    proceeding.** [worker/src/common.ts [67]](https://github.com/dreamhunter2333/cloudflare_temp_email/pull/432/files#diff-fcc08fd5aa3c190d0d45c7e3dd208e5ee831d360b272fdd5869607cf472c5eb1R67-R67) ```diff -checkNameBlockList(c, name); +await checkNameBlockList(c, name); ```
    Suggestion importance[1-10]: 10 Why: This suggestion is crucial as it ensures that the asynchronous `checkNameBlockList` function completes before proceeding, preventing potential issues with unhandled promises.
    10
    Best practice
    Rethrow the error after logging it in the checkNameBlockList function to ensure the caller is aware of the error ___ **To improve error handling, rethrow the error after logging it in the
    checkNameBlockList function. This will ensure that the caller is aware of the error.** [worker/src/common.ts [144]](https://github.com/dreamhunter2333/cloudflare_temp_email/pull/432/files#diff-fcc08fd5aa3c190d0d45c7e3dd208e5ee831d360b272fdd5869607cf472c5eb1R144-R144) ```diff console.error(error); +throw error; ```
    Suggestion importance[1-10]: 9 Why: Rethrowing the error after logging it improves error handling by ensuring that the caller is aware of the error, which is a best practice.
    9
    Enhancement
    Simplify the getDefaultDomains function by avoiding redundant checks ___ **Simplify the getDefaultDomains function by directly returning the result of
    getDomains if c.env.DEFAULT_DOMAINS is undefined or null, and avoid redundant
    checks.** [worker/src/utils.ts [100-104]](https://github.com/dreamhunter2333/cloudflare_temp_email/pull/432/files#diff-87b77c56897ffc7830773b3d665c51ecf2210b44921bef7098a1dd6d64e56db6R100-R104) ```diff -if (c.env.DEFAULT_DOMAINS == undefined || c.env.DEFAULT_DOMAINS == null) { +if (!c.env.DEFAULT_DOMAINS) { return getDomains(c); } -const domains = getStringArray(c.env.DEFAULT_DOMAINS); -return domains || getDomains(c); +return getStringArray(c.env.DEFAULT_DOMAINS) || getDomains(c); ```
    Suggestion importance[1-10]: 8 Why: This suggestion improves code readability and efficiency by removing redundant checks, making the function more concise.
    8
    Maintainability
    Move the name.replace line after the name checks for better readability and maintainability ___ **To improve readability and maintainability, move the name.replace line after the
    name checks are completed.** [worker/src/common.ts [64-69]](https://github.com/dreamhunter2333/cloudflare_temp_email/pull/432/files#diff-fcc08fd5aa3c190d0d45c7e3dd208e5ee831d360b272fdd5869607cf472c5eb1R64-R69) ```diff -name = name.replace(getNameRegex(c), ''); // check name if (enableCheckNameRegex) { - checkNameBlockList(c, name); + await checkNameBlockList(c, name); checkNameRegex(c, name); } +// remove special characters +name = name.replace(getNameRegex(c), ''); ```
    Suggestion importance[1-10]: 7 Why: This suggestion improves code readability and maintainability by logically ordering the operations, although it is not crucial for functionality.
    7