|  | @@ -26,7 +26,6 @@ TRACIM_SPECIAL_KEY_HEADER = 'X-Tracim-Key'
 | 
	
		
			
			| 26 | 26 |  CONTENT_TYPE_TEXT_PLAIN = 'text/plain'
 | 
	
		
			
			| 27 | 27 |  CONTENT_TYPE_TEXT_HTML = 'text/html'
 | 
	
		
			
			| 28 | 28 |  
 | 
	
		
			
			| 29 |  | -IMAP_SEEN_FLAG = imapclient.SEEN
 | 
	
		
			
			| 30 | 29 |  IMAP_CHECKED_FLAG = imapclient.FLAGGED
 | 
	
		
			
			| 31 | 30 |  
 | 
	
		
			
			| 32 | 31 |  MAIL_FETCHER_FILELOCK_TIMEOUT = 10
 | 
	
	
		
			
			|  | @@ -342,13 +341,9 @@ class MailFetcher(object):
 | 
	
		
			
			| 342 | 341 |          """
 | 
	
		
			
			| 343 | 342 |          messages = []
 | 
	
		
			
			| 344 | 343 |  
 | 
	
		
			
			| 345 |  | -        logger.debug(self, 'Fetch unseen messages')
 | 
	
		
			
			| 346 |  | -        uids = imapc.search(['UNSEEN'])
 | 
	
		
			
			| 347 |  | -        logger.debug(self, 'Found {} unseen mails'.format(
 | 
	
		
			
			| 348 |  | -            len(uids),
 | 
	
		
			
			| 349 |  | -        ))
 | 
	
		
			
			| 350 |  | -        imapc.add_flags(uids, IMAP_SEEN_FLAG)
 | 
	
		
			
			| 351 |  | -        logger.debug(self, 'Temporary Flag {} mails as seen'.format(
 | 
	
		
			
			|  | 344 | +        logger.debug(self, 'Fetch unflagged messages')
 | 
	
		
			
			|  | 345 | +        uids = imapc.search(['UNFLAGGED'])
 | 
	
		
			
			|  | 346 | +        logger.debug(self, 'Found {} unflagged mails'.format(
 | 
	
		
			
			| 352 | 347 |              len(uids),
 | 
	
		
			
			| 353 | 348 |          ))
 | 
	
		
			
			| 354 | 349 |          for msgid, data in imapc.fetch(uids, ['BODY.PEEK[]']).items():
 | 
	
	
		
			
			|  | @@ -421,17 +416,13 @@ class MailFetcher(object):
 | 
	
		
			
			| 421 | 416 |                          str(r.status_code),
 | 
	
		
			
			| 422 | 417 |                          details,
 | 
	
		
			
			| 423 | 418 |                      ))
 | 
	
		
			
			| 424 |  | -                # Flag all correctly checked mail, unseen the others
 | 
	
		
			
			|  | 419 | +                # Flag all correctly checked mail
 | 
	
		
			
			| 425 | 420 |                  if r.status_code in [200, 204, 400]:
 | 
	
		
			
			| 426 | 421 |                      imapc.add_flags((mail.uid,), IMAP_CHECKED_FLAG)
 | 
	
		
			
			| 427 |  | -                else:
 | 
	
		
			
			| 428 |  | -                    imapc.remove_flags((mail.uid,), IMAP_SEEN_FLAG)
 | 
	
		
			
			| 429 | 422 |              # TODO - G.M - Verify exception correctly works
 | 
	
		
			
			| 430 | 423 |              except requests.exceptions.Timeout as e:
 | 
	
		
			
			| 431 | 424 |                  log = 'Timeout error to transmit fetched mail to tracim : {}'
 | 
	
		
			
			| 432 | 425 |                  logger.error(self, log.format(str(e)))
 | 
	
		
			
			| 433 |  | -                imapc.remove_flags((mail.uid,), IMAP_SEEN_FLAG)
 | 
	
		
			
			| 434 | 426 |              except requests.exceptions.RequestException as e:
 | 
	
		
			
			| 435 | 427 |                  log = 'Fail to transmit fetched mail to tracim : {}'
 | 
	
		
			
			| 436 | 428 |                  logger.error(self, log.format(str(e)))
 | 
	
		
			
			| 437 |  | -                imapc.remove_flags((mail.uid,), IMAP_SEEN_FLAG)
 |