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

feat: |Worker| NO_LIMIT_SEND_ROLE support multi role splited by ',' #588

Merged
merged 1 commit into from
Feb 22, 2025

Conversation

dreamhunter2333
Copy link
Owner

@dreamhunter2333 dreamhunter2333 commented Feb 19, 2025

PR Type

enhancement, documentation


Description

  • Support for multiple roles in NO_LIMIT_SEND_ROLE using comma separation.

  • Added getSplitStringListValue utility function for splitting strings.

  • Updated relevant files to use getSplitStringListValue for NO_LIMIT_SEND_ROLE.

  • Documentation updates for the new NO_LIMIT_SEND_ROLE format.


Changes walkthrough 📝

Relevant files
Enhancement
worker_config.ts
Update NO_LIMIT_SEND_ROLE to support multiple roles           

worker/src/admin_api/worker_config.ts

  • Import getSplitStringListValue from utils.
  • Use getSplitStringListValue for NO_LIMIT_SEND_ROLE.
  • +2/-2     
    index.ts
    Enhance NO_LIMIT_SEND_ROLE handling in mails API                 

    worker/src/mails_api/index.ts

  • Import getSplitStringListValue from utils.
  • Use getSplitStringListValue for NO_LIMIT_SEND_ROLE.
  • +3/-2     
    send_mail_api.ts
    Support multiple roles in send mail API                                   

    worker/src/mails_api/send_mail_api.ts

  • Import getSplitStringListValue from utils.
  • Use getSplitStringListValue for NO_LIMIT_SEND_ROLE.
  • +3/-2     
    utils.ts
    Add utility function for splitting strings                             

    worker/src/utils.ts

  • Add getSplitStringListValue function to split strings by delimiter.
  • +10/-1   
    Documentation
    CHANGELOG.md
    Update changelog for NO_LIMIT_SEND_ROLE enhancement           

    CHANGELOG.md

    • Add entry for NO_LIMIT_SEND_ROLE multi-role support.
    +1/-0     
    cli.md
    Update CLI documentation for NO_LIMIT_SEND_ROLE                   

    vitepress-docs/docs/en/cli.md

    • Document new format for NO_LIMIT_SEND_ROLE.
    +2/-1     
    worker-vars.md
    Update worker vars documentation for NO_LIMIT_SEND_ROLE   

    vitepress-docs/docs/zh/guide/worker-vars.md

    • Document new format for NO_LIMIT_SEND_ROLE.
    +1/-1     
    wrangler.toml.template
    Update wrangler template for NO_LIMIT_SEND_ROLE                   

    worker/wrangler.toml.template

    • Document new format for NO_LIMIT_SEND_ROLE.
    +2/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Possible Issue

    Ensure that user_role is properly defined before using it in the is_no_limit_send_balance condition to avoid potential runtime errors.

    const no_limit_roles = getSplitStringListValue(c.env.NO_LIMIT_SEND_ROLE);
    const is_no_limit_send_balance = user_role && no_limit_roles.includes(user_role);
    Possible Issue

    Ensure that user_role is properly defined before using it in the is_no_limit_send_balance condition to avoid potential runtime errors.

    const no_limit_roles = getSplitStringListValue(c.env.NO_LIMIT_SEND_ROLE);
    const is_no_limit_send_balance = user_role && no_limit_roles.includes(user_role);

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add null check to avoid errors

    Add a null check for the value parameter in the getSplitStringListValue function to
    avoid potential runtime errors when value is null or undefined.

    worker/src/utils.ts [72-79]

     export const getSplitStringListValue = (
         value: any, demiliter: string = ","
     ): string[] => {
    +    if (!value) return [];
         const valueToSplit = getStringValue(value);
         return valueToSplit.split(demiliter)
             .map((item: string) => item.trim())
             .filter((item: string) => item.length > 0);
     }
    Suggestion importance[1-10]: 8

    __

    Why: Adding a null check for the value parameter in the getSplitStringListValue function is a good practice to avoid potential runtime errors when value is null or undefined. This improves the robustness of the function.

    Medium

    @dreamhunter2333 dreamhunter2333 merged commit 3a542a8 into main Feb 22, 2025
    1 check passed
    @dreamhunter2333 dreamhunter2333 deleted the feature/dev branch February 22, 2025 08:58
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant