end
def self.suggest_labels_for path
- if path =~ /inbox/i
- [path.intern]
- else
- []
- end
+ path =~ /([^\/]*inbox[^\/]*)/i ? [$1.downcase.intern] : []
end
def host; @parsed_uri.host; end
end
def ssl?; @parsed_uri.scheme == 'imaps' end
- def check
- return unless start_offset
-
- ids =
- @mutex.synchronize do
- unsynchronized_scan_mailbox
- @ids
- end
-
- start = ids.index(cur_offset || start_offset) or raise OutOfSyncSourceError, "Unknown message id #{cur_offset || start_offset}."
- end
+ def check; end # do nothing because anything we do will be too slow,
+ # and we'll catch the errors later.
## is this necessary? TODO: remove maybe
def == o; o.is_a?(IMAP) && o.uri == self.uri && o.username == self.username; end
@ids << id
@imap_state[id] = { :id => v.seqno, :flags => v.attr["FLAGS"] }
end
+ Redwood::log "done fetching IMAP headers"
end
synchronized :scan_mailbox
end
end.join
-
-
raise exception if exception
end
imap_id = @imap_state[id][:id]
result = fetch(imap_id, (fields + ['RFC822.SIZE', 'INTERNALDATE']).uniq).first
got_id = make_id result
- raise OutOfSyncSourceError, "IMAP message mismatch: requested #{id}, got #{got_id}." unless got_id == id
+
+ ## I've turned off the following sanity check because Microsoft Exchange fails it.
+ ## Exchange actually reports two different INTERNALDATEs for the exact same message
+ ## when queried at different points in time.
+ ##
+ ##
+ ## RFC2060 defines the semantics of INTERNALDATE for messages that arrive
+ ## via SMTP for via various IMAP commands, but states that "All other
+ ## cases are implementation defined.". Great, thanks guys, yet another
+ ## useless field.
+ ##
+ ## Of course no OTHER imap server I've encountered returns DIFFERENT values for
+ ## the SAME message. But it's Microsoft; what do you expect? If their programmers
+ ## were any good they'd be working at Google.
+
+ # raise OutOfSyncSourceError, "IMAP message mismatch: requested #{id}, got #{got_id}." unless got_id == id
fields.map { |f| result.attr[f] or raise FatalSourceError, "empty response from IMAP server: #{f}" }
end