Skip to content

Commit

Permalink
Merge pull request #301 from Peppermint-Lab/fix/imap-error
Browse files Browse the repository at this point in the history
fix: imap error
  • Loading branch information
potts99 committed Apr 10, 2024
2 parents c48af2c + 02766a4 commit 63c116d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
36 changes: 2 additions & 34 deletions apps/api/src/lib/imap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,6 @@ const year = date.getFullYear();
//@ts-ignore
const d = new Date([year, month, today]);

function parseEmailContent(emailText: any) {
const lines = emailText.split("\n");
const parsedData = {
name: "",
email: "",
phoneNumbers: [],
addresses: [],
companyDetails: "",
};

let inAddressSection = false;

lines.forEach((line: any) => {
if (line.includes("@")) {
parsedData.email = line.trim();
} else if (line.includes("US:") || line.includes("UK:")) {
//@ts-ignore
parsedData.phoneNumbers.push(line.trim());
} else if (line.includes("ISO")) {
parsedData.companyDetails = line.trim();
} else if (line.trim() === "North America:" || line.trim() === "Europe:") {
inAddressSection = true;
//@ts-ignore
} else if (inAddressSection && line.trim() !== "") {
//@ts-ignore
parsedData.addresses.push(line.trim());
}
});

return parsedData;
}

export const getEmails = async () => {
try {
const queues = await client.emailQueue.findMany({});
Expand Down Expand Up @@ -87,7 +55,7 @@ export const getEmails = async () => {

console.log("from", from);

const parsedData = parseEmailContent(textAsHtml);
// const parsedData = parseEmailContent(textAsHtml);

if (subject !== undefined && subject.includes("Re:")) {
return await client.comment.create({
Expand Down Expand Up @@ -116,7 +84,7 @@ export const getEmails = async () => {
isComplete: Boolean(false),
priority: "Low",
fromImap: Boolean(true),
detail: html,
detail: html ? html : textAsHtml,
},
});

Expand Down
2 changes: 1 addition & 1 deletion apps/client/layouts/newLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ export default function NewLayout({ children }: any) {
{user.isAdmin && (
<Link href="https://github.com/Peppermint-Lab/peppermint/releases">
<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">
Version 0.4.6
Version 0.4.7
</span>
</Link>
)}
Expand Down

0 comments on commit 63c116d

Please sign in to comment.