get mailcount on footer

This commit is contained in:
ClaraCrazy 2025-12-13 02:22:40 +01:00
parent 31e7594b2f
commit 21a6e760e5
No known key found for this signature in database
GPG key ID: EBBC896ACB497011
5 changed files with 49 additions and 16 deletions

View file

@ -50,6 +50,10 @@ class MailProcessingService extends EventEmitter {
return this.mailRepository.getAll() return this.mailRepository.getAll()
} }
getCount() {
return this.mailRepository.mailCount()
}
onInitialLoadDone() { onInitialLoadDone() {
this.initialLoadDone = true this.initialLoadDone = true
console.log(`Initial load done, got ${this.mailRepository.mailCount()} mails`) console.log(`Initial load done, got ${this.mailRepository.mailCount()} mails`)

View file

@ -6,7 +6,6 @@ body {
min-height: 100vh; min-height: 100vh;
background-color: #131516; background-color: #131516;
color: #cccccc; color: #cccccc;
} }
body::-webkit-scrollbar { body::-webkit-scrollbar {
@ -14,18 +13,20 @@ body::-webkit-scrollbar {
} }
main { main {
flex: 1; /* keep footer at the bottom */ flex: 1;
/* keep footer at the bottom */
} }
a { a {
color: #cccccc; color: #cccccc;
} }
h1 { h1 {
font-size: 3rem; font-size: 3rem;
} }
h3 { h3 {
font-size: 2rem; font-size: 2rem;
} }
a.no-link-color { a.no-link-color {
@ -60,23 +61,36 @@ text-muted {
text-align: center text-align: center
} }
.footer-two {
margin-top: -2rem
}
/* Reset apple form styles */ /* Reset apple form styles */
input, textarea, select, select:active, select:focus, select:hover {
input,
textarea,
select,
select:active,
select:focus,
select:hover {
-webkit-appearance: none; -webkit-appearance: none;
-moz-appearance: none; -moz-appearance: none;
appearance: none; border-radius: 0; appearance: none;
border-radius: 0;
background-image: none; background-image: none;
} }
#login { #login {
padding-top: 15vh; padding-top: 15vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
max-width: 600px; max-width: 600px;
margin: auto; margin: auto;
} }
#login h1, #login h4 { #login h1,
#login h4 {
text-align: center; text-align: center;
} }
@ -97,7 +111,8 @@ input, textarea, select, select:active, select:focus, select:hover {
z-index: 999; z-index: 999;
} }
#login input[type="text"], #login select { #login input[type="text"],
#login select {
border-radius: 0.4rem; border-radius: 0.4rem;
color: #cccccc; color: #cccccc;
font-size: 1.6rem; font-size: 1.6rem;
@ -130,7 +145,7 @@ input, textarea, select, select:active, select:focus, select:hover {
flex-wrap: wrap; flex-wrap: wrap;
} }
#login .buttons > * { #login .buttons>* {
width: 100%; width: 100%;
flex: 1; flex: 1;
font-size: 1.3rem; font-size: 1.3rem;
@ -138,9 +153,9 @@ input, textarea, select, select:active, select:focus, select:hover {
.mail_attachments { .mail_attachments {
width: 80%; width: 80%;
padding-left:10% padding-left: 10%
} }
label { label {
display: inline; display: inline;
} }

View file

@ -16,12 +16,14 @@ const sanitizeAddress = param('address').customSanitizer(
} }
) )
router.get('^/:address([^@/]+@[^@/]+)', sanitizeAddress, (req, res, _next) => { router.get('^/:address([^@/]+@[^@/]+)', sanitizeAddress, async(req, res, _next) => {
const mailProcessingService = req.app.get('mailProcessingService') const mailProcessingService = req.app.get('mailProcessingService')
const count = await mailProcessingService.getCount()
res.render('inbox', { res.render('inbox', {
title: `${config.http.branding[0]} | ` + req.params.address, title: `${config.http.branding[0]} | ` + req.params.address,
purgeTime: purgeTime, purgeTime: purgeTime,
address: req.params.address, address: req.params.address,
count: count,
mailSummaries: mailProcessingService.getMailSummaries(req.params.address), mailSummaries: mailProcessingService.getMailSummaries(req.params.address),
branding: config.http.branding, branding: config.http.branding,
}) })
@ -33,6 +35,7 @@ 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 count = await mailProcessingService.getCount()
const mail = await mailProcessingService.getOneFullMail( const mail = await mailProcessingService.getOneFullMail(
req.params.address, req.params.address,
req.params.uid req.params.uid
@ -49,6 +52,7 @@ router.get(
title: mail.subject + " | " + req.params.address, title: mail.subject + " | " + req.params.address,
purgeTime: purgeTime, purgeTime: purgeTime,
address: req.params.address, address: req.params.address,
count: count,
mail, mail,
uid: req.params.uid, uid: req.params.uid,
branding: config.http.branding, branding: config.http.branding,
@ -58,6 +62,7 @@ router.get(
'error', { 'error', {
purgeTime: purgeTime, purgeTime: purgeTime,
address: req.params.address, address: req.params.address,
count: count,
message: 'This mail could not be found. It either does not exist or has been deleted from our servers!', message: 'This mail could not be found. It either does not exist or has been deleted from our servers!',
branding: config.http.branding branding: config.http.branding
@ -117,6 +122,7 @@ router.get(
) )
var index = mail.attachments.findIndex(attachment => attachment.checksum === req.params.checksum); var index = mail.attachments.findIndex(attachment => attachment.checksum === req.params.checksum);
const attachment = mail.attachments[index]; const attachment = mail.attachments[index];
const count = await mailProcessingService.getCount()
if (attachment) { if (attachment) {
try { try {
res.set('Content-Disposition', `attachment; filename=${attachment.filename}`); res.set('Content-Disposition', `attachment; filename=${attachment.filename}`);
@ -132,6 +138,7 @@ router.get(
'error', { 'error', {
purgeTime: purgeTime, purgeTime: purgeTime,
address: req.params.address, address: req.params.address,
count: count,
message: 'This attachment could not be found. It either does not exist or has been deleted from our servers!', message: 'This attachment could not be found. It either does not exist or has been deleted from our servers!',
branding: config.http.branding, branding: config.http.branding,
} }
@ -153,6 +160,7 @@ 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 count = await mailProcessingService.getCount()
mail = await mailProcessingService.getOneFullMail( mail = await mailProcessingService.getOneFullMail(
req.params.address, req.params.address,
req.params.uid, req.params.uid,
@ -171,6 +179,7 @@ router.get(
'error', { 'error', {
purgeTime: purgeTime, purgeTime: purgeTime,
address: req.params.address, address: req.params.address,
count: count,
message: 'This mail could not be found. It either does not exist or has been deleted from our servers!', message: 'This mail could not be found. It either does not exist or has been deleted from our servers!',
branding: config.http.branding, branding: config.http.branding,
} }

View file

@ -9,12 +9,14 @@ const helper = new(Helper)
const purgeTime = helper.purgeTimeElemetBuilder() const purgeTime = helper.purgeTimeElemetBuilder()
router.get('/', (req, res, _next) => { router.get('/', async(req, res, _next) => {
const count = await req.app.get('mailProcessingService').getCount()
res.render('login', { res.render('login', {
title: `${config.http.branding[0]} | Your temporary Inbox`, title: `${config.http.branding[0]} | Your temporary Inbox`,
username: randomWord(), username: randomWord(),
purgeTime: purgeTime, purgeTime: purgeTime,
domains: helper.getDomains(), domains: helper.getDomains(),
count: count,
branding: config.http.branding, branding: config.http.branding,
example: config.email.examples.account, example: config.email.examples.account,
}) })
@ -38,8 +40,9 @@ router.post(
check('username').isLength({ min: 1 }), check('username').isLength({ min: 1 }),
check('domain').isIn(config.email.domains) check('domain').isIn(config.email.domains)
], ],
(req, res) => { async(req, res) => {
const errors = validationResult(req) const errors = validationResult(req)
const count = await req.app.get('mailProcessingService').getCount()
if (!errors.isEmpty()) { if (!errors.isEmpty()) {
return res.render('login', { return res.render('login', {
userInputError: true, userInputError: true,
@ -47,6 +50,7 @@ router.post(
purgeTime: purgeTime, purgeTime: purgeTime,
username: randomWord(), username: randomWord(),
domains: helper.getDomains(), domains: helper.getDomains(),
count: count,
branding: config.http.branding, branding: config.http.branding,
}) })
} }

View file

@ -28,7 +28,8 @@
{% block footer %} {% block footer %}
<section class="container footer"> <section class="container footer">
<hr> <hr>
<h4>{{ branding[0] }} offered by <a href="{{ branding[2] }}" style="text-decoration:underline" target="_blank">{{ branding[1] }}</a> | All Emails will be deleted after {{ purgeTime | raw }} | This project is <a href="https://github.com/crazyco-xyz/48hr.email" style="text-decoration:underline" target="_blank">open-source ♥</a></h4> <h4>{{ branding[0] }} offered by <a href="{{ branding[2] }}" style="text-decoration:underline" target="_blank">{{ branding[1] }}</a> | All Emails will be deleted after {{ purgeTime | raw }} | Currently handling <u><i>{{ count }}</i></u> Emails</h4>
<h4 class="container footer-two"> This project is <a href="https://github.com/crazyco-xyz/48hr.email" style="text-decoration:underline" target="_blank">open-source ♥</a></h4>
</section> </section>
{% endblock %} {% endblock %}