Compare commits

...

4 Commits

Author SHA1 Message Date
ClaraCrazy f2e6923953
Potential fix? 2024-11-11 19:15:19 +01:00
ClaraCrazy 2636f5f56a
remove unnecessary console.logs 2024-11-11 19:00:07 +01:00
ClaraCrazy 05bb74e1d3
Make config usage more clear 2024-11-11 18:51:50 +01:00
ClaraCrazy 159cd9942e
Fix manual deletion
The fact this has gone unnoticed for so long is genuinely pathetic
2024-11-11 18:51:00 +01:00
3 changed files with 7 additions and 9 deletions

View File

@ -23,12 +23,12 @@ const config = {
http: { // HTTP configuration http: { // HTTP configuration
port: normalizePort(process.env.HTTP_PORT || 3000), // http port to listen on port: normalizePort(process.env.HTTP_PORT || 3000), // http port to listen on
branding: process.env.HTTP_BRANDING || ["48hr.email", "CrazyCo", "https://crazyco.xyz"], // branding [service_title, company_name, company_url] branding: process.env.HTTP_BRANDING || ["48hr.email", "CrazyCo", "https://crazyco.xyz"], // branding [service_title, company_name, company_url]
displaySort: process.env.HTTP_DISPLAY_SORT || 0, // Sorting logic used for display: displaySort: process.env.HTTP_DISPLAY_SORT || 0, // Sorting logic used for displaying available email domains:
// 0 does not modify, // 0 does not modify,
// 1 sorts alphabetically, // 1 sorts alphabetically,
// 2 sorts alphabetically and only shuffles the first item, // 2 sorts alphabetically and only shuffles the first item,
// 3 shuffles all // 3 shuffles all
hideOther: process.env.HTTP_HIDE_OTHER || false, // Hide other emails in the list and only show first (true) or show all (false) hideOther: process.env.HTTP_HIDE_OTHER || false, // Hide other email domains in the list and only show first (true) or show all (false)
}, },
} }

View File

@ -107,11 +107,8 @@ class Helper {
shuffleFirstItem(array) { shuffleFirstItem(array) {
let first = array[Math.floor(Math.random()*array.length)] let first = array[Math.floor(Math.random()*array.length)]
console.log(first)
array = array.filter((value)=>value!=first); array = array.filter((value)=>value!=first);
console.log(array)
array = [first].concat(array) array = [first].concat(array)
console.log(array)
return array return array
} }

View File

@ -202,15 +202,16 @@ class ImapService extends EventEmitter {
async deleteOldMails(deleteMailsBefore) { async deleteOldMails(deleteMailsBefore) {
let uids = [] let uids = []
if (helper.moreThanOneDay(moment(), deleteMailsBefore)) { if (helper.moreThanOneDay(moment(), deleteMailsBefore)) {
//fetch mails from date -1day (calculated in MS) to avoid wasting resources
deleteMailsBefore = deleteMailsBefore - 24 * 60 * 60 * 1000
uids = await this._searchWithoutFetch([ uids = await this._searchWithoutFetch([
['!DELETED'], ['!DELETED'],
['BEFORE', deleteMailsBefore] ['BEFORE', deleteMailsBefore]
]) ])
} else { } else {
//fetch mails from date -1day (calculated in MS) to avoid wasting resources
deleteMailsBefore = new Date(moment() - 24 * 60 * 60 * 1000)
uids = await this._searchWithoutFetch([ uids = await this._searchWithoutFetch([
['!DELETED'] ['!DELETED'],
['BEFORE', deleteMailsBefore]
]) ])
} }
@ -244,7 +245,7 @@ class ImapService extends EventEmitter {
*/ */
async deleteSpecificEmail(uid) { async deleteSpecificEmail(uid) {
debug(`deleting mails ${uid}`) debug(`deleting mails ${uid}`)
if (!this.config.http.examples.uids.includes(parseInt(uid))) { if (!this.config.email.examples.uids.includes(parseInt(uid))) {
await this.connection.deleteMessage(uid) await this.connection.deleteMessage(uid)
console.log(`deleted mail with UID: ${uid}.`) console.log(`deleted mail with UID: ${uid}.`)
this.emit(ImapService.EVENT_DELETED_MAIL, uid) this.emit(ImapService.EVENT_DELETED_MAIL, uid)