mirror of
https://github.com/Crazyco-xyz/48hr.email.git
synced 2026-01-10 19:39:34 +01:00
[Chore]: Update legacy naming scheme
This commit is contained in:
parent
51d608c2c0
commit
a48ae65885
19 changed files with 44 additions and 42 deletions
6
app.js
6
app.js
|
|
@ -18,9 +18,9 @@ if (fs.existsSync(envPath)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = require('./application/config')
|
const config = require('./application/config-service')
|
||||||
const debug = require('debug')('48hr-email:app')
|
const debug = require('debug')('48hr-email:app')
|
||||||
const Helper = require('./application/helper')
|
const Helper = require('./application/helper-service')
|
||||||
const helper = new(Helper)
|
const helper = new(Helper)
|
||||||
const { app, io, server } = require('./infrastructure/web/web')
|
const { app, io, server } = require('./infrastructure/web/web')
|
||||||
const ClientNotification = require('./infrastructure/web/client-notification')
|
const ClientNotification = require('./infrastructure/web/client-notification')
|
||||||
|
|
@ -337,4 +337,4 @@ server.on('error', error => {
|
||||||
console.error('Fatal web server error', error)
|
console.error('Fatal web server error', error)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// config.js
|
// config.js
|
||||||
require("dotenv").config({ quiet: true });
|
require("dotenv").config({ quiet: true });
|
||||||
const debug = require('debug')('48hr-email:config')
|
const debug = require('debug')('48hr-email:config-service')
|
||||||
|
|
||||||
// Migration helper: warn about deprecated env vars
|
// Migration helper: warn about deprecated env vars
|
||||||
if (process.env.USER_SESSION_SECRET && !process.env.HTTP_SESSION_SECRET) {
|
if (process.env.USER_SESSION_SECRET && !process.env.HTTP_SESSION_SECRET) {
|
||||||
|
|
@ -131,4 +131,4 @@ if (!config.email.domains.length) {
|
||||||
|
|
||||||
debug(`Configuration validated successfully: ${config.email.domains.length} domains${config.uxDebugMode ? ' (UX DEBUG MODE)' : ''}`)
|
debug(`Configuration validated successfully: ${config.email.domains.length} domains${config.uxDebugMode ? ' (UX DEBUG MODE)' : ''}`)
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
const debug = require('debug')('48hr-email:crypto-detector')
|
const debug = require('debug')('48hr-email:crypto-service')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detects cryptographic keys and signatures in email attachments
|
* Detects cryptographic keys and signatures in email attachments
|
||||||
*/
|
*/
|
||||||
class CryptoDetector {
|
class CryptoService {
|
||||||
constructor() {
|
constructor() {
|
||||||
// Common cryptographic file extensions
|
// Common cryptographic file extensions
|
||||||
this.cryptoExtensions = [
|
this.cryptoExtensions = [
|
||||||
|
|
@ -408,4 +408,4 @@ class CryptoDetector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = CryptoDetector
|
module.exports = CryptoService
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
const config = require('./config')
|
const config = require('./config-service')
|
||||||
const debug = require('debug')('48hr-email:helper')
|
const debug = require('debug')('48hr-email:helper-service')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
|
|
||||||
class Helper {
|
class HelperService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize our config into a proper timestamp, so we know what emails to purge
|
* Normalize our config into a proper timestamp, so we know what emails to purge
|
||||||
|
|
@ -283,4 +283,4 @@ class Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Helper
|
module.exports = HelperService
|
||||||
|
|
@ -5,9 +5,9 @@ const addressparser = require('nodemailer/lib/addressparser')
|
||||||
const retry = require('async-retry')
|
const retry = require('async-retry')
|
||||||
const debug = require('debug')('48hr-email:imap-manager')
|
const debug = require('debug')('48hr-email:imap-manager')
|
||||||
const Mail = require('../domain/mail')
|
const Mail = require('../domain/mail')
|
||||||
const Helper = require('./helper')
|
const Helper = require('./helper-service')
|
||||||
const helper = new(Helper)
|
const helper = new(Helper)
|
||||||
const config = require('./config')
|
const config = require('./config-service')
|
||||||
|
|
||||||
|
|
||||||
// Just adding some missing functions to imap-simple... :-)
|
// Just adding some missing functions to imap-simple... :-)
|
||||||
|
|
@ -380,8 +380,8 @@ class ImapService extends EventEmitter {
|
||||||
async _searchWithoutFetch(searchCriteria) {
|
async _searchWithoutFetch(searchCriteria) {
|
||||||
const imapUnderlying = this.connection.imap;
|
const imapUnderlying = this.connection.imap;
|
||||||
// If searching by UID and the list is too long, batch it
|
// If searching by UID and the list is too long, batch it
|
||||||
const UID_BATCH_SIZE = 500;
|
const UID_BATCH_SIZE = this.config.imap.fetchChunkSize;
|
||||||
// Detect UID search: ['UID', [array]] or ['UID', '1:1000']
|
// Detect UID search: ['UID', [array]] or ['UID', '1:500']
|
||||||
if (Array.isArray(searchCriteria) && searchCriteria.length === 1 && Array.isArray(searchCriteria[0]) && searchCriteria[0][0] === 'UID' && Array.isArray(searchCriteria[0][1]) && searchCriteria[0][1].length > UID_BATCH_SIZE) {
|
if (Array.isArray(searchCriteria) && searchCriteria.length === 1 && Array.isArray(searchCriteria[0]) && searchCriteria[0][0] === 'UID' && Array.isArray(searchCriteria[0][1]) && searchCriteria[0][1].length > UID_BATCH_SIZE) {
|
||||||
const allUids = searchCriteria[0][1];
|
const allUids = searchCriteria[0][1];
|
||||||
let allResults = [];
|
let allResults = [];
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const debug = require('debug')('48hr-email:imap-processor')
|
const debug = require('debug')('48hr-email:imap-processor')
|
||||||
const ImapService = require('./imap-service')
|
const ImapService = require('./imap-service')
|
||||||
const Helper = require('./helper')
|
const Helper = require('./helper-service')
|
||||||
const config = require('./config')
|
const config = require('./config-service')
|
||||||
const helper = new(Helper)
|
const helper = new(Helper)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const Helper = require('../application/helper')
|
const Helper = require('../application/helper-service')
|
||||||
const helper = new Helper()
|
const helper = new Helper()
|
||||||
|
|
||||||
class ApiTokenRepository {
|
class ApiTokenRepository {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const debug = require('debug')('48hr-email:mail-summary-store')
|
const debug = require('debug')('48hr-email:mail-summary-store')
|
||||||
const MultiMap = require('mnemonist/multi-map')
|
const MultiMap = require('mnemonist/multi-map')
|
||||||
const config = require('../application/config')
|
const config = require('../application/config-service')
|
||||||
|
|
||||||
class MailRepository {
|
class MailRepository {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -87,4 +87,4 @@ class MailRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MailRepository
|
module.exports = MailRepository
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const debug = require('debug')('48hr-email:stats-store');
|
const debug = require('debug')('48hr-email:stats-store');
|
||||||
const config = require('../application/config');
|
const config = require('../application/config-service');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ router.get('/account', requireAuth, async(req, res) => {
|
||||||
const userRepository = req.app.get('userRepository')
|
const userRepository = req.app.get('userRepository')
|
||||||
const inboxLock = req.app.get('inboxLock')
|
const inboxLock = req.app.get('inboxLock')
|
||||||
const mailProcessingService = req.app.get('mailProcessingService')
|
const mailProcessingService = req.app.get('mailProcessingService')
|
||||||
const Helper = require('../../../application/helper')
|
const Helper = require('../../../application/helper-service')
|
||||||
const helper = new Helper()
|
const helper = new Helper()
|
||||||
|
|
||||||
// In UX debug mode, reset mock data to initial state only on fresh page load
|
// In UX debug mode, reset mock data to initial state only on fresh page load
|
||||||
|
|
@ -350,4 +350,4 @@ router.post('/account/delete',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ const router = new express.Router()
|
||||||
const { body, validationResult } = require('express-validator')
|
const { body, validationResult } = require('express-validator')
|
||||||
const debug = require('debug')('48hr-email:auth-routes')
|
const debug = require('debug')('48hr-email:auth-routes')
|
||||||
const { redirectIfAuthenticated } = require('../middleware/auth')
|
const { redirectIfAuthenticated } = require('../middleware/auth')
|
||||||
const config = require('../../../application/config')
|
const config = require('../../../application/config-service')
|
||||||
const templateContext = require('../template-context')
|
const templateContext = require('../template-context')
|
||||||
|
|
||||||
// Simple in-memory rate limiters for registration and login
|
// Simple in-memory rate limiters for registration and login
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const router = new express.Router()
|
const router = new express.Router()
|
||||||
const config = require('../../../application/config')
|
const config = require('../../../application/config-service')
|
||||||
const templateContext = require('../template-context')
|
const templateContext = require('../template-context')
|
||||||
const debug = require('debug')('48hr-email:routes')
|
const debug = require('debug')('48hr-email:routes')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ const router = new express.Router()
|
||||||
const { check, validationResult } = require('express-validator')
|
const { check, validationResult } = require('express-validator')
|
||||||
const debug = require('debug')('48hr-email:routes')
|
const debug = require('debug')('48hr-email:routes')
|
||||||
const randomWord = require('random-word')
|
const randomWord = require('random-word')
|
||||||
const config = require('../../../application/config')
|
const config = require('../../../application/config-service')
|
||||||
const templateContext = require('../template-context')
|
const templateContext = require('../template-context')
|
||||||
|
|
||||||
router.get('/', async(req, res, next) => {
|
router.get('/', async(req, res, next) => {
|
||||||
|
|
@ -71,4 +71,4 @@ router.post(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ const router = new express.Router()
|
||||||
const { param, body, validationResult } = require('express-validator')
|
const { param, body, validationResult } = require('express-validator')
|
||||||
const debug = require('debug')('48hr-email:routes')
|
const debug = require('debug')('48hr-email:routes')
|
||||||
|
|
||||||
const config = require('../../../application/config')
|
const config = require('../../../application/config-service')
|
||||||
const Helper = require('../../../application/helper')
|
const Helper = require('../../../application/helper-service')
|
||||||
const CryptoDetector = require('../../../application/crypto-detector')
|
const CryptoService = require('../../../application/crypto-service')
|
||||||
const templateContext = require('../template-context')
|
const templateContext = require('../template-context')
|
||||||
const helper = new(Helper)
|
const helper = new(Helper)
|
||||||
const cryptoDetector = new CryptoDetector()
|
const cryptoService = new CryptoService()
|
||||||
const { checkLockAccess } = require('../middleware/lock')
|
const { checkLockAccess } = require('../middleware/lock')
|
||||||
const { requireAuth, optionalAuth } = require('../middleware/auth')
|
const { requireAuth, optionalAuth } = require('../middleware/auth')
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ router.get(
|
||||||
res.set('Cache-Control', 'private, max-age=600')
|
res.set('Cache-Control', 'private, max-age=600')
|
||||||
|
|
||||||
// Detect cryptographic keys in attachments
|
// Detect cryptographic keys in attachments
|
||||||
const cryptoAttachments = cryptoDetector.detectCryptoAttachments(mail.attachments)
|
const cryptoAttachments = cryptoService.detectCryptoAttachments(mail.attachments)
|
||||||
debug(`Found ${cryptoAttachments.length} cryptographic attachments`)
|
debug(`Found ${cryptoAttachments.length} cryptographic attachments`)
|
||||||
|
|
||||||
debug(`Rendering email view for UID ${req.params.uid}`)
|
debug(`Rendering email view for UID ${req.params.uid}`)
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ router.get('/api', async(req, res) => {
|
||||||
const statisticsStore = req.app.get('statisticsStore')
|
const statisticsStore = req.app.get('statisticsStore')
|
||||||
const imapService = req.app.get('imapService')
|
const imapService = req.app.get('imapService')
|
||||||
const mailProcessingService = req.app.get('mailProcessingService')
|
const mailProcessingService = req.app.get('mailProcessingService')
|
||||||
const Helper = require('../../../application/helper')
|
const Helper = require('../../../application/helper-service')
|
||||||
const helper = new Helper()
|
const helper = new Helper()
|
||||||
|
|
||||||
// Update largest UID before getting stats (if IMAP is ready)
|
// Update largest UID before getting stats (if IMAP is ready)
|
||||||
|
|
@ -129,4 +129,4 @@ router.get('/api', async(req, res) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const config = require('../../application/config')
|
const config = require('../../application/config-service')
|
||||||
const Helper = require('../../application/helper')
|
const Helper = require('../../application/helper-service')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template Context Builder
|
* Template Context Builder
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const sanitizeHtml = require('sanitize-html')
|
const sanitizeHtml = require('sanitize-html')
|
||||||
const config = require('../../../application/config')
|
const config = require('../../../application/config-service')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transformes <a> tags to always use "noreferrer noopener" and open in a new window.
|
* Transformes <a> tags to always use "noreferrer noopener" and open in a new window.
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ const compression = require('compression')
|
||||||
const helmet = require('helmet')
|
const helmet = require('helmet')
|
||||||
const socketio = require('socket.io')
|
const socketio = require('socket.io')
|
||||||
|
|
||||||
const config = require('../../application/config')
|
const config = require('../../application/config-service')
|
||||||
const createApiRouter = require('./api/router')
|
const createApiRouter = require('./api/router')
|
||||||
const inboxRouter = require('./routes/inbox')
|
const inboxRouter = require('./routes/inbox')
|
||||||
const homeRouter = require('./routes/home')
|
const homeRouter = require('./routes/home')
|
||||||
|
|
@ -120,7 +120,7 @@ app.use((req, res, next) => {
|
||||||
app.use(async(req, res, next) => {
|
app.use(async(req, res, next) => {
|
||||||
const mailProcessingService = req.app.get('mailProcessingService')
|
const mailProcessingService = req.app.get('mailProcessingService')
|
||||||
const imapService = req.app.get('imapService')
|
const imapService = req.app.get('imapService')
|
||||||
const Helper = require('../../application/helper')
|
const Helper = require('../../application/helper-service')
|
||||||
const helper = new Helper()
|
const helper = new Helper()
|
||||||
|
|
||||||
if (mailProcessingService) {
|
if (mailProcessingService) {
|
||||||
|
|
@ -243,4 +243,4 @@ server.on('listening', () => {
|
||||||
server.emit('ready')
|
server.emit('ready')
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = { app, io, server }
|
module.exports = { app, io, server }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const HelperService = require("../application/helper-service")
|
||||||
|
|
||||||
// Test script to verify domains are loaded correctly
|
// Test script to verify domains are loaded correctly
|
||||||
const helper = new Helper()
|
const helper = new HelperService()
|
||||||
const domains = helper.getDomains()
|
const domains = helper.getDomains()
|
||||||
console.log('\nDomains from helper.getDomains():', domains)
|
console.log('\nDomains from helper.getDomains():', domains)
|
||||||
console.log('Length:', domains ? domains.length : undefined)
|
console.log('Length:', domains ? domains.length : undefined)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue