Mercurial > hg > soundsoftware-site
diff lib/redmine/imap.rb @ 1464:261b3d9a4903 redmine-2.4
Update to Redmine 2.4 branch rev 12663
author | Chris Cannam |
---|---|
date | Tue, 14 Jan 2014 14:37:42 +0000 |
parents | 433d4f72a19b |
children | e248c7af89ec |
line wrap: on
line diff
--- a/lib/redmine/imap.rb Fri Jun 14 09:05:06 2013 +0100 +++ b/lib/redmine/imap.rb Tue Jan 14 14:37:42 2014 +0000 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2012 Jean-Philippe Lang +# Copyright (C) 2006-2013 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -29,25 +29,27 @@ imap = Net::IMAP.new(host, port, ssl) imap.login(imap_options[:username], imap_options[:password]) unless imap_options[:username].nil? imap.select(folder) - imap.search(['NOT', 'SEEN']).each do |message_id| - msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822'] - logger.debug "Receiving message #{message_id}" if logger && logger.debug? + imap.uid_search(['NOT', 'SEEN']).each do |uid| + msg = imap.uid_fetch(uid,'RFC822')[0].attr['RFC822'] + logger.debug "Receiving message #{uid}" if logger && logger.debug? if MailHandler.receive(msg, options) - logger.debug "Message #{message_id} successfully received" if logger && logger.debug? + logger.debug "Message #{uid} successfully received" if logger && logger.debug? if imap_options[:move_on_success] - imap.copy(message_id, imap_options[:move_on_success]) + imap.uid_copy(uid, imap_options[:move_on_success]) end - imap.store(message_id, "+FLAGS", [:Seen, :Deleted]) + imap.uid_store(uid, "+FLAGS", [:Seen, :Deleted]) else - logger.debug "Message #{message_id} can not be processed" if logger && logger.debug? - imap.store(message_id, "+FLAGS", [:Seen]) + logger.debug "Message #{uid} can not be processed" if logger && logger.debug? + imap.uid_store(uid, "+FLAGS", [:Seen]) if imap_options[:move_on_failure] - imap.copy(message_id, imap_options[:move_on_failure]) - imap.store(message_id, "+FLAGS", [:Deleted]) + imap.uid_copy(uid, imap_options[:move_on_failure]) + imap.uid_store(uid, "+FLAGS", [:Deleted]) end end end imap.expunge + imap.logout + imap.disconnect end private