vmail 2.3.9 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -207,8 +207,9 @@ message window. Watch the status line.
207
207
  If you have `notify-send` (Linux) or `growlnotify` (OS X) installed on
208
208
  your system, Vmail will also poll your INBOX every 30 seconds for new
209
209
  messages. If it detects a new message, it will alert you through your
210
- notification program. **NOTE**: You will still have to press `u` in the
211
- Vmail interface to force the new messages to display.
210
+ notification program. **NOTE**: This is an alert mechanism only;
211
+ you will still have to manually check for new messages in the Vmail
212
+ interface to force the new messages to display.
212
213
 
213
214
  ## Switching mailboxes, moving messages, copying messages to another mailbox
214
215
 
@@ -214,6 +214,9 @@ module Vmail
214
214
  log "- got seqnos: #{ids.inspect}"
215
215
  log "- getting seqnos > #{self.max_seqno}"
216
216
  new_ids = ids.select {|seqno| seqno > self.max_seqno}
217
+ # reset the max_seqno
218
+ self.max_seqno = ids.max
219
+ log "- setting max_seqno to #{self.max_seqno}"
217
220
  log "- new uids found: #{new_ids.inspect}"
218
221
  new_ids
219
222
  end
@@ -222,7 +225,6 @@ module Vmail
222
225
  prime_connection
223
226
  new_ids = check_for_new_messages
224
227
  if !new_ids.empty?
225
- self.max_seqno = new_ids[-1]
226
228
  @ids = @ids + new_ids
227
229
  message_ids = fetch_and_cache_headers(new_ids)
228
230
  res = get_message_headers(message_ids)
@@ -1,6 +1,7 @@
1
1
  module Vmail
2
2
  class InboxPoller < ImapClient
3
3
 
4
+
4
5
  # This is a second IMAP client operating in a separate process
5
6
 
6
7
  def start_polling
@@ -32,26 +33,36 @@ module Vmail
32
33
  def update
33
34
  new_ids = check_for_new_messages
34
35
  if !new_ids.empty?
35
- self.max_seqno = new_ids[-1]
36
36
  @ids = @ids + new_ids
37
- message_ids = fetch_and_cache_headers(new_ids)
38
- res = get_message_headers(message_ids)
37
+ res = uncached_headers(new_ids).map {|m| m[:sender] }.join(", ")
39
38
  @notifier.call "Vmail: new email", "from #{res}"
40
39
  end
41
40
  rescue
42
41
  log "VMAIL_ERROR: #{[$!.message, $!.backtrace].join("\n")}"
43
42
  end
44
43
 
45
- def get_message_headers(message_ids)
46
- messages = message_ids.map {|message_id|
47
- m = Message[message_id]
48
- if m.nil?
49
- raise "Message #{message_id} not found"
50
- end
51
- m
52
- }
53
- res = messages.map {|m| m.sender }.join(", ")
54
- res
44
+ # doesn't try to access Sequel / sqlite3
45
+ def uncached_headers(id_set)
46
+ log "Fetching headers for #{id_set.size} messages"
47
+ results = reconnect_if_necessary do
48
+ @imap.fetch(id_set, ["FLAGS", "ENVELOPE", "RFC822.SIZE", "UID"])
49
+ end
50
+ results.reverse.map do |x|
51
+ envelope = x.attr["ENVELOPE"]
52
+ message_id = envelope.message_id
53
+ subject = Mail::Encodings.unquote_and_convert_to((envelope.subject || ''), 'UTF-8')
54
+ recipients = ((envelope.to || []) + (envelope.cc || [])).map {|a| extract_address(a)}.join(', ')
55
+ sender = extract_address envelope.from.first
56
+ uid = x.attr["UID"]
57
+ params = {
58
+ subject: (subject || ''),
59
+ flags: x.attr['FLAGS'].join(','),
60
+ date: Time.parse(envelope.date).localtime.to_s,
61
+ size: x.attr['RFC822.SIZE'],
62
+ sender: sender,
63
+ recipients: recipients
64
+ }
65
+ end
55
66
  end
56
67
 
57
68
  def log(string)
@@ -1,3 +1,3 @@
1
1
  module Vmail
2
- VERSION = '2.3.9'
2
+ VERSION = '2.4.0'
3
3
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
- - 3
8
- - 9
9
- version: 2.3.9
7
+ - 4
8
+ - 0
9
+ version: 2.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi