mirror of
				https://github.com/Crazyco-xyz/48hr.email.git
				synced 2025-11-04 15:26:33 +01:00 
			
		
		
		
	Compare commits
	
		
			4 commits
		
	
	
		
			f2e6923953
			...
			e158fac414
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						e158fac414 | ||
| 
							 | 
						367c4a688b | ||
| 
							 | 
						80d8ecfad2 | ||
| 
							 | 
						e99a8b55e0 | 
					 2 changed files with 9 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -201,17 +201,15 @@ class ImapService extends EventEmitter {
 | 
			
		|||
	 */
 | 
			
		||||
	async deleteOldMails(deleteMailsBefore) {
 | 
			
		||||
		let uids = []
 | 
			
		||||
		if (helper.moreThanOneDay(moment(), deleteMailsBefore)) {
 | 
			
		||||
		//fetch mails from date +1day (calculated in MS) to avoid wasting resources and to fix imaps missing time-awareness
 | 
			
		||||
		if (helper.moreThanOneDay(moment() + 24 * 60 * 60 * 1000, deleteMailsBefore)) {
 | 
			
		||||
			uids = await this._searchWithoutFetch([
 | 
			
		||||
				['!DELETED'],
 | 
			
		||||
				['BEFORE', deleteMailsBefore]
 | 
			
		||||
			])
 | 
			
		||||
		} 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([
 | 
			
		||||
				['!DELETED'],
 | 
			
		||||
				['BEFORE', deleteMailsBefore]
 | 
			
		||||
			])
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -220,8 +218,8 @@ class ImapService extends EventEmitter {
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		const DeleteOlderThan = helper.purgeTimeStamp()
 | 
			
		||||
 | 
			
		||||
		const uidsWithHeaders = await this._getMailHeaders(uids)
 | 
			
		||||
 | 
			
		||||
		uidsWithHeaders.forEach(mail => {
 | 
			
		||||
			if (mail['attributes'].date > DeleteOlderThan || this.config.email.examples.uids.includes(parseInt(mail['attributes'].uid))) {
 | 
			
		||||
				uids = uids.filter(uid => uid !== mail['attributes'].uid)
 | 
			
		||||
| 
						 | 
				
			
			@ -347,6 +345,7 @@ class ImapService extends EventEmitter {
 | 
			
		|||
 | 
			
		||||
	async _getMailHeaders(uids) {
 | 
			
		||||
		const fetchOptions = {
 | 
			
		||||
			envelope: true,
 | 
			
		||||
			bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)'],
 | 
			
		||||
			struct: false
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,11 @@ class MailRepository {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	add(to, mailSummary) {
 | 
			
		||||
		if (to !== undefined) {
 | 
			
		||||
			this.mailSummaries.set(to.toLowerCase(), mailSummary)
 | 
			
		||||
		} else {
 | 
			
		||||
			debug('IMAP reported no recipient for mail, ignoring', mailSummary)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	removeUid(uid, address) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue