/raw endpoint working
parent
b0d9014a00
commit
7e73268bb7
|
@ -262,7 +262,7 @@ class ImapService extends EventEmitter {
|
||||||
return Mail.create(to, from, date, subject, uid)
|
return Mail.create(to, from, date, subject, uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchOneFullMail(to, uid) {
|
async fetchOneFullMail(to, uid, raw = false) {
|
||||||
if (!this.connection) {
|
if (!this.connection) {
|
||||||
// Here we 'fail fast' instead of waiting for the connection.
|
// Here we 'fail fast' instead of waiting for the connection.
|
||||||
throw new Error('imap connection not ready')
|
throw new Error('imap connection not ready')
|
||||||
|
@ -281,9 +281,14 @@ class ImapService extends EventEmitter {
|
||||||
if (messages.length === 0) {
|
if (messages.length === 0) {
|
||||||
return("womp womp")
|
return("womp womp")
|
||||||
}
|
}
|
||||||
const fullBody = _.find(messages[0].parts, {which: ''})
|
if (!raw) {
|
||||||
|
const fullBody = await _.find(messages[0].parts, {which: ''})
|
||||||
return simpleParser(fullBody.body)
|
return simpleParser(fullBody.body)
|
||||||
|
} else {
|
||||||
|
return messages[0].parts[1].body
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async _getAllUids() {
|
async _getAllUids() {
|
||||||
// We ignore mails that are flagged as DELETED, but have not been removed (expunged) yet.
|
// We ignore mails that are flagged as DELETED, but have not been removed (expunged) yet.
|
||||||
|
|
|
@ -37,8 +37,8 @@ class MailProcessingService extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getOneFullMail(address, uid) {
|
getOneFullMail(address, uid, raw = false) {
|
||||||
return this.cachedFetchFullMail(address, uid)
|
return this.cachedFetchFullMail(address, uid, raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllMailSummaries() {
|
getAllMailSummaries() {
|
||||||
|
|
|
@ -6,7 +6,11 @@ body {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background-color: #131516;
|
background-color: #131516;
|
||||||
color: #cccccc;
|
color: #cccccc;
|
||||||
overflow: hidden;
|
|
||||||
|
}
|
||||||
|
|
||||||
|
body::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
|
@ -101,15 +101,17 @@ router.get(
|
||||||
async (req, res, next) => {
|
async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const mailProcessingService = req.app.get('mailProcessingService')
|
const mailProcessingService = req.app.get('mailProcessingService')
|
||||||
const mail = await mailProcessingService.getOneFullMail(
|
mail = await mailProcessingService.getOneFullMail(
|
||||||
req.params.address,
|
req.params.address,
|
||||||
req.params.uid
|
req.params.uid,
|
||||||
|
true
|
||||||
)
|
)
|
||||||
|
mail = mail.replace(/(?:\r\n|\r|\n)/g, '<br>')
|
||||||
if (mail && mail != "womp womp") {
|
if (mail && mail != "womp womp") {
|
||||||
// Emails are immutable, cache if found
|
// Emails are immutable, cache if found
|
||||||
res.set('Cache-Control', 'private, max-age=600')
|
res.set('Cache-Control', 'private, max-age=600')
|
||||||
res.render('raw', {
|
res.render('raw', {
|
||||||
title: mail.subject + " | raw | " + req.params.address,
|
title: req.params.uid + " | raw | " + req.params.address,
|
||||||
mail
|
mail
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
{% extends 'layout.twig' %}
|
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
<head>
|
||||||
|
<title>{{ title }}</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">
|
||||||
|
<meta name="darkreader" content="stfu">
|
||||||
|
|
||||||
<div class="mail_body">
|
<meta name="description" content="Dont give shady companies your real email. Use 48hr.email to protect your privacy!">
|
||||||
<p>Not yet...</p>
|
<meta property="og:image" content="/images/logo.png">
|
||||||
{% for header, html in mail.headers %}
|
|
||||||
<p>This doesnt work rn</p>
|
|
||||||
{# TODO:
|
|
||||||
Make raw email. show all headers, preferrably even attachment raws and ofc mail.
|
|
||||||
need inspiration? open a mail "raw" in gmail. thats what I wanna mirror.
|
|
||||||
#}
|
|
||||||
|
|
||||||
{% endfor %}
|
<link rel="shortcut icon" href="/images/logo.ico">
|
||||||
</div>
|
<link rel='stylesheet' href='/dependencies/milligram.css' />
|
||||||
|
<link rel='stylesheet' href='/stylesheets/custom.css' />
|
||||||
|
|
||||||
|
<script src="/socket.io/socket.io.js" defer="true"></script>
|
||||||
|
<script src="/javascripts/notifications.js" defer="true"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
{{ mail | raw }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue