Skip to content

Commit 63c116d

Browse files
authored
Merge pull request #301 from Peppermint-Lab/fix/imap-error
fix: imap error
2 parents c48af2c + 02766a4 commit 63c116d

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

apps/api/src/lib/imap.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,6 @@ const year = date.getFullYear();
1414
//@ts-ignore
1515
const d = new Date([year, month, today]);
1616

17-
function parseEmailContent(emailText: any) {
18-
const lines = emailText.split("\n");
19-
const parsedData = {
20-
name: "",
21-
email: "",
22-
phoneNumbers: [],
23-
addresses: [],
24-
companyDetails: "",
25-
};
26-
27-
let inAddressSection = false;
28-
29-
lines.forEach((line: any) => {
30-
if (line.includes("@")) {
31-
parsedData.email = line.trim();
32-
} else if (line.includes("US:") || line.includes("UK:")) {
33-
//@ts-ignore
34-
parsedData.phoneNumbers.push(line.trim());
35-
} else if (line.includes("ISO")) {
36-
parsedData.companyDetails = line.trim();
37-
} else if (line.trim() === "North America:" || line.trim() === "Europe:") {
38-
inAddressSection = true;
39-
//@ts-ignore
40-
} else if (inAddressSection && line.trim() !== "") {
41-
//@ts-ignore
42-
parsedData.addresses.push(line.trim());
43-
}
44-
});
45-
46-
return parsedData;
47-
}
48-
4917
export const getEmails = async () => {
5018
try {
5119
const queues = await client.emailQueue.findMany({});
@@ -87,7 +55,7 @@ export const getEmails = async () => {
8755

8856
console.log("from", from);
8957

90-
const parsedData = parseEmailContent(textAsHtml);
58+
// const parsedData = parseEmailContent(textAsHtml);
9159

9260
if (subject !== undefined && subject.includes("Re:")) {
9361
return await client.comment.create({
@@ -116,7 +84,7 @@ export const getEmails = async () => {
11684
isComplete: Boolean(false),
11785
priority: "Low",
11886
fromImap: Boolean(true),
119-
detail: html,
87+
detail: html ? html : textAsHtml,
12088
},
12189
});
12290

apps/client/layouts/newLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ export default function NewLayout({ children }: any) {
952952
{user.isAdmin && (
953953
<Link href="https://github.com/Peppermint-Lab/peppermint/releases">
954954
<span className="inline-flex items-center rounded-md bg-green-700/10 px-3 py-2 text-xs font-medium text-green-600 ring-1 ring-inset ring-green-500/20">
955-
Version 0.4.6
955+
Version 0.4.7
956956
</span>
957957
</Link>
958958
)}

0 commit comments

Comments
 (0)