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: |Actions| Tag build add worker-with-wasm-mail-parser.zip #590

Merged
merged 1 commit into from
Feb 22, 2025

Conversation

dreamhunter2333
Copy link
Owner

@dreamhunter2333 dreamhunter2333 commented Feb 22, 2025

User description

#589


PR Type

enhancement, documentation


Description

  • Added support for mail-parser-wasm-worker in build process.

  • Updated GitHub Actions workflow to include worker-with-wasm-mail-parser.zip.

  • Enhanced documentation for UI and CLI deployment of mail-parser-wasm-worker.

  • Improved error logging in sendWebhook function.


Changes walkthrough 📝

Relevant files
Enhancement
common.ts
Enhance sendWebhook function with better logging                 

worker/src/common.ts

  • Improved formatting of sendWebhook function.
  • Added detailed error logging for webhook failures.
  • +5/-5     
    Configuration changes
    tag_build.yml
    Update GitHub Actions to include mail-parser-wasm-worker 

    .github/workflows/tag_build.yml

  • Added steps to build and include mail-parser-wasm-worker.
  • Updated release upload to include worker-with-wasm-mail-parser.zip.
  • +15/-1   
    Documentation
    CHANGELOG.md
    Update changelog for wasm mail parser support                       

    CHANGELOG.md

  • Documented the addition of worker-with-wasm-mail-parser.zip in build.
  • +1/-0     
    mail_parser_wasm_worker.md
    Document UI and CLI deployment for mail-parser-wasm-worker

    vitepress-docs/docs/zh/guide/feature/mail_parser_wasm_worker.md

  • Added UI deployment instructions for mail-parser-wasm-worker.
  • Enhanced CLI deployment instructions.
  • +20/-2   

    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:

    🎫 Ticket compliance analysis 🔶

    589 - Partially compliant

    Compliant requirements:

    • Configure mail-parser-wasm-worker for the project.

    Non-compliant requirements:

    • Ensure emails from cloudns display content correctly.
    • Ensure message pusher displays email content correctly.

    Requires further human verification:

    • Ensure emails from cloudns display content correctly.
    • Ensure message pusher displays email content correctly.
    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🔒 Security concerns

    Sensitive information exposure:
    The sendWebhook function logs sensitive information (headers, body) on error, which could expose sensitive data.

    ⚡ Recommended focus areas for review

    Possible Issue

    The sendWebhook function logs sensitive information (headers, body) on error, which could expose sensitive data.

    export async function sendWebhook(
        settings: WebhookSettings, formatMap: WebhookMail
    ): Promise<{ success: boolean, message?: string }> {
        // send webhook
        let body = settings.body;
        for (const key of Object.keys(formatMap)) {
            body = body.replace(
                new RegExp(`\\$\\{${key}\\}`, "g"),
                JSON.stringify(
                    formatMap[key as keyof WebhookMail]
                ).replace(/^"(.*)"$/, '$1')
            );
        }
        const response = await fetch(settings.url, {
            method: settings.method,
            headers: JSON.parse(settings.headers),
            body: body
        });
        if (!response.ok) {
            console.log("send webhook error", settings.url, settings.method, settings.headers, body);
            console.log("send webhook error", response.status, response.statusText);
            return { success: false, message: `send webhook error: ${response.status} ${response.statusText}` };

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add error handling for JSON parsing

    Add error handling for the JSON.parse call on settings.headers to catch and handle
    potential parsing errors.

    worker/src/common.ts [357]

    -headers: JSON.parse(settings.headers),
    +let headers;
    +try {
    +    headers = JSON.parse(settings.headers);
    +} catch (error) {
    +    console.log("Invalid JSON in headers", error);
    +    return { success: false, message: "Invalid JSON in headers" };
    +}
    Suggestion importance[1-10]: 9

    __

    Why: Adding error handling for JSON parsing is crucial to prevent runtime errors and ensure robustness. This suggestion addresses a potential issue that could cause the function to fail if the JSON is invalid.

    High
    General
    Verify integrity of downloaded zip file

    Add a step to verify the integrity of the downloaded
    worker-with-wasm-mail-parser.zip file to ensure it is not corrupted.

    .github/workflows/tag_build.yml [47-66]

     - name: Move worker.js
     ...
    +- name: Verify worker-with-wasm-mail-parser.zip integrity
    +  run: |
    +    cd worker
    +    unzip -tq worker-with-wasm-mail-parser.zip
     - name: Upload to Release
    Suggestion importance[1-10]: 7

    __

    Why: Verifying the integrity of the downloaded zip file is a good practice to ensure that the file is not corrupted, which can prevent potential issues during deployment.

    Medium
    Remove duplicate semicolon

    Remove the duplicate semicolon at the end of the return statement in the
    getAllowDomains function.

    worker/src/common.ts [339]

    -return user_role?.domains || getDefaultDomains(c);;
    +return user_role?.domains || getDefaultDomains(c);
    Suggestion importance[1-10]: 3

    __

    Why: Removing the duplicate semicolon is a minor improvement that enhances code cleanliness and readability, but it does not significantly impact functionality.

    Low

    @dreamhunter2333 dreamhunter2333 merged commit c3987d3 into main Feb 22, 2025
    1 check passed
    @dreamhunter2333 dreamhunter2333 deleted the feature/dev branch February 22, 2025 10:51
    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