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: |Telegram Bot| add new command to clean invalid jwts #543

Merged
merged 1 commit into from
Jan 4, 2025

Conversation

dreamhunter2333
Copy link
Owner

@dreamhunter2333 dreamhunter2333 commented Jan 4, 2025

PR Type

enhancement


Description

  • Add new Telegram bot command to clean invalid JWTs.

  • Update jwtListToAddressData function to return invalid JWTs.

  • Modify Telegram bot commands list to include the new command.

  • Update CHANGELOG.md to reflect the new feature.


Changes walkthrough 📝

Relevant files
Enhancement
common.ts
Enhance `jwtListToAddressData` to handle invalid JWTs       

worker/src/telegram_api/common.ts

  • Update jwtListToAddressData to return invalid JWTs.
  • Add handling for invalid JWTs in the address list.
  • +7/-2     
    telegram.ts
    Add `cleaninvalidadress` command to Telegram bot                 

    worker/src/telegram_api/telegram.ts

  • Add new command cleaninvalidadress to Telegram bot.
  • Implement logic to clean invalid JWTs and update address list.
  • +24/-0   
    Documentation
    CHANGELOG.md
    Update CHANGELOG for new Telegram bot command                       

    CHANGELOG.md

    • Document new Telegram bot command for cleaning invalid JWTs.
    +1/-0     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    github-actions bot commented Jan 4, 2025

    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

    Command Description Mismatch

    The description for the new cleaninvalidadress command appears to be a copy-paste error from the mails command. It should be updated to accurately describe the new command's functionality.

    command: "cleaninvalidadress",
    description: "查看邮件, 请输入 /mails <邮箱地址>, 不输入地址默认查看第一个地址"

    Copy link

    github-actions bot commented Jan 4, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Correct the command description to accurately describe the "cleaninvalidadress" functionality

    Ensure the command description for "cleaninvalidadress" accurately reflects its
    functionality to avoid confusion.

    worker/src/telegram_api/telegram.ts [44-47]

     {
         command: "cleaninvalidadress",
    -    description: "查看邮件, 请输入 /mails <邮箱地址>, 不输入地址默认查看第一个地址"
    +    description: "清理无效地址凭证, 请输入 /cleaninvalidadress"
     },
    Suggestion importance[1-10]: 9

    Why: The existing description for the "cleaninvalidadress" command is incorrect and misleading. Correcting it to accurately reflect the command's functionality is crucial for user understanding and proper usage.

    9
    Possible issue
    Add a check to ensure jwtList is an array before proceeding

    Add a check to ensure jwtList is an array before proceeding to avoid potential
    runtime errors.

    worker/src/telegram_api/telegram.ts [193]

    -const jwtList = await c.env.KV.get<string[]>(`${CONSTANTS.TG_KV_PREFIX}:${userId}`, 'json') || [];
    +const jwtList = Array.isArray(await c.env.KV.get<string[]>(`${CONSTANTS.TG_KV_PREFIX}:${userId}`, 'json')) ? await c.env.KV.get<string[]>(`${CONSTANTS.TG_KV_PREFIX}:${userId}`, 'json') : [];
    Suggestion importance[1-10]: 8

    Why: Adding a check to ensure jwtList is an array before proceeding helps prevent potential runtime errors, improving the robustness and reliability of the code.

    8

    @dreamhunter2333 dreamhunter2333 merged commit 479322c into main Jan 4, 2025
    @dreamhunter2333 dreamhunter2333 deleted the feature/dev branch January 4, 2025 17:52
    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