Project

General

Profile

Defect #9032 » 8979_project_leader_user_activation_V1.2.1.diff

Jérôme BATAILLE, 2011-08-10 17:20

View differences:

imap.rb (copie de travail)
imap = Net::IMAP.new(host, port, ssl)
imap.login(imap_options[:username], imap_options[:password]) unless imap_options[:username].nil?
imap.select(folder)
# Get the unread messages
imap.search(['NOT', 'SEEN']).each do |message_id|
# Get the message body
msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
logger.debug "Receiving message #{message_id}" if logger && logger.debug?
# Redmine manages the message
if MailHandler.receive(msg, options)
logger.debug "Message #{message_id} successfully received" if logger && logger.debug?
# Ennder trace the message enveloppe (to, cc, etc.)
if logger && logger.debug?
_enveloppe = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
logger.debug "Message #{message_id} successfully received, to.emails=[#{ trace_to(_enveloppe) }]"
fi
if imap_options[:move_on_success]
imap.copy(message_id, imap_options[:move_on_success])
# Ennder new trace
logger.debug "move to Archive" if logger && logger.debug?
# Ennder Defect #9030 manage exception if the Imap Archive folder does not exist
begin
imap.copy(message_id, imap_options[:move_on_success])
rescue
logger.error "Exception : #{$!} (#{imap_options[:move_on_success]}), the folder does NOT exist (at the same level as INBOX)" if logger
end
end
# Ennder new trace
logger.debug "store Seen, Deleted..." if logger && logger.debug?
imap.store(message_id, "+FLAGS", [:Seen, :Deleted])
else
logger.debug "Message #{message_id} can not be processed" if logger && logger.debug?
logger.error "Message #{message_id} can not be processed" if logger
# Ennder new trace
logger.debug "store Seen..." if logger && logger.debug?
imap.store(message_id, "+FLAGS", [:Seen])
if imap_options[:move_on_failure]
imap.copy(message_id, imap_options[:move_on_failure])
#Ennder new trace
logger.debug "copy..." if logger && logger.debug?
# Ennder Defect #9030 manage exception if the Imap Archive folder does not exist
begin
imap.copy(message_id, imap_options[:move_on_failure])
rescue
logger.error "Exception : #{$!} (#{imap_options[:move_on_failure]}), the folder does NOT exist (at the same level as INBOX)" if logger
end
# Ennder new trace
logger.debug "store Deleted..." if logger && logger.debug?
imap.store(message_id, "+FLAGS", [:Deleted])
end
end
......
def logger
RAILS_DEFAULT_LOGGER
end
#Ennder
def trace_to(p_enveloppe)
_to_mails = ''
p_enveloppe.to.each do |_to|
_to_mails += _to.mailbox + '@' + _to.host + ','
end
_to_mails
end
end
end
end
    (1-1/1)