This commit is contained in:
parent
6dcd96ab06
commit
74a7a7d66b
|
@ -1,10 +1,9 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import { Server } from "http";
|
|
||||||
import { SMTPServer } from "smtp-server";
|
import { SMTPServer } from "smtp-server";
|
||||||
import { simpleParser } from "mailparser";
|
import mailparser from "mailparser";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ReactDOMServer from "react-dom/server";
|
import ReactDOMServer from "react-dom/server";
|
||||||
import { Builder, Parser } from "xml2js";
|
import xml2js from "xml2js";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import cryptoRandomString from "crypto-random-string";
|
import cryptoRandomString from "crypto-random-string";
|
||||||
|
|
||||||
|
@ -56,14 +55,14 @@ export const emailServer = new SMTPServer({
|
||||||
return [path];
|
return [path];
|
||||||
});
|
});
|
||||||
if (paths.length === 0) return callback();
|
if (paths.length === 0) return callback();
|
||||||
const email = await simpleParser(stream);
|
const email = await mailparser.simpleParser(stream);
|
||||||
const { entry } = Entry({
|
const { entry } = Entry({
|
||||||
title: email.subject,
|
title: email.subject,
|
||||||
author: email.from.text,
|
author: email.from.text,
|
||||||
content: typeof email.html !== "boolean" ? email.html : email.textAsHtml
|
content: typeof email.html !== "boolean" ? email.html : email.textAsHtml
|
||||||
});
|
});
|
||||||
for (const path of paths) {
|
for (const path of paths) {
|
||||||
const xml = await new Parser().parseStringPromise(
|
const xml = await new xml2js.Parser().parseStringPromise(
|
||||||
fs.readFileSync(path).toString()
|
fs.readFileSync(path).toString()
|
||||||
);
|
);
|
||||||
xml.feed.updated = now();
|
xml.feed.updated = now();
|
||||||
|
@ -287,5 +286,5 @@ function renderHTML(component: React.ReactElement): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderXML(xml: object): string {
|
function renderXML(xml: object): string {
|
||||||
return new Builder().buildObject(xml);
|
return new xml2js.Builder().buildObject(xml);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue