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

fix: telegram query email do not pass parsedEmailContext #555

Merged
merged 1 commit into from
Jan 11, 2025

Conversation

dreamhunter2333
Copy link
Owner

@dreamhunter2333 dreamhunter2333 commented Jan 11, 2025

PR Type

Bug fix


Description

  • Fix issue with telegram query email not passing parsedEmailContext.

  • Update parseMail function call to pass an object with rawEmail.


Changes walkthrough 📝

Relevant files
Bug fix
telegram.ts
Fix telegram query email parsing                                                 

worker/src/telegram_api/telegram.ts

  • Fix parseMail function call to pass rawEmail as an object.
+1/-1     

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

@dreamhunter2333 dreamhunter2333 merged commit e161eb5 into main Jan 11, 2025
1 check passed
@dreamhunter2333 dreamhunter2333 deleted the feature/dev branch January 11, 2025 10:14
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

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

Possible Issue

Ensure that the parseMail function correctly handles the new object format with rawEmail and that it does not introduce any unexpected behavior or errors.

const { raw, id: mailId, created_at } = await c.env.DB.prepare(
    `SELECT * FROM raw_mails where address = ? `
    + ` order by id desc limit 1 offset ?`
).bind(
    queryAddress, mailIndex
).first<{ raw: string, id: string, created_at: string }>() || {};
const { mail } = raw ? await parseMail({ rawEmail: raw }, queryAddress, created_at) : { mail: "已经没有邮件了" };

Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
General
Add error handling to the parseMail function to ensure any parsing errors are caught and logged

Add error handling for the parseMail function to catch and log any potential errors
that might occur during the parsing process.

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

-const { mail } = raw ? await parseMail({ rawEmail: raw }, queryAddress, created_at) : { mail: "已经没有邮件了" };
+let mail;
+if (raw) {
+    try {
+        ({ mail } = await parseMail({ rawEmail: raw }, queryAddress, created_at));
+    } catch (error) {
+        console.error('Error parsing mail:', error);
+        mail = "邮件解析失败";
+    }
+} else {
+    mail = "已经没有邮件了";
+}
Suggestion importance[1-10]: 9

Why: Adding error handling for the parseMail function is crucial to ensure that any potential errors during the parsing process are caught and logged, preventing the application from crashing and providing useful debugging information.

9

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