mirror of
				https://github.com/Crazyco-xyz/48hr.email.git
				synced 2025-11-04 07:16:32 +01:00 
			
		
		
		
	retire userRemoveUid function, refactor removeUid
This commit is contained in:
		
							parent
							
								
									1d42862c46
								
							
						
					
					
						commit
						92674272d5
					
				
					 2 changed files with 17 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -32,7 +32,7 @@ class MailProcessingService extends EventEmitter {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	deleteSpecificEmail(adress, uid) {
 | 
			
		||||
		if (this.mailRepository.UserRemoveUid(adress, uid) == true) {
 | 
			
		||||
		if (this.mailRepository.removeUid(uid, adress) == true) {
 | 
			
		||||
			this.imapService.deleteSpecificEmail(uid)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,31 +30,22 @@ class MailRepository {
 | 
			
		|||
		this.mailSummaries.set(to.toLowerCase(), mailSummary)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	UserRemoveUid(address, uid) {
 | 
			
		||||
		var deleted = false
 | 
			
		||||
		// TODO: make this more efficient, looping through each email is not cool.
 | 
			
		||||
		this.mailSummaries.forEachAssociation((mails, to) => {
 | 
			
		||||
			mails
 | 
			
		||||
				.filter(mail => mail.uid === parseInt(uid) & to == address)
 | 
			
		||||
				.forEach(mail => {
 | 
			
		||||
					this.mailSummaries.remove(to, mail)
 | 
			
		||||
					debug('removed ', mail.date, to, mail.subject)
 | 
			
		||||
					deleted = true
 | 
			
		||||
				})
 | 
			
		||||
		})
 | 
			
		||||
		return deleted
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	removeUid(uid) {
 | 
			
		||||
		// TODO: make this more efficient, looping through each email is not cool.
 | 
			
		||||
		this.mailSummaries.forEachAssociation((mails, to) => {
 | 
			
		||||
			mails
 | 
			
		||||
				.filter(mail => mail.uid === parseInt(uid))
 | 
			
		||||
				.forEach(mail => {
 | 
			
		||||
					this.mailSummaries.remove(to, mail)
 | 
			
		||||
					debug('removed ', mail.date, to, mail.subject)
 | 
			
		||||
				})
 | 
			
		||||
		})
 | 
			
		||||
	removeUid(uid, address) {
 | 
			
		||||
		if (!this.config.http.examples.uids.includes(parseInt(uid))) {
 | 
			
		||||
			var deleted = false
 | 
			
		||||
			// TODO: make this more efficient, looping through each email is not cool.
 | 
			
		||||
			this.mailSummaries.forEachAssociation((mails, to) => {
 | 
			
		||||
				mails
 | 
			
		||||
					.filter(mail => mail.uid === parseInt(uid) && (address ? to == address : true))
 | 
			
		||||
					.forEach(mail => {
 | 
			
		||||
						this.mailSummaries.remove(to, mail)
 | 
			
		||||
						debug('removed ', mail.date, to, mail.subject)
 | 
			
		||||
						deleted = true
 | 
			
		||||
					})
 | 
			
		||||
			})
 | 
			
		||||
			return deleted
 | 
			
		||||
		}
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mailCount() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue