mail_room 0.5.0 → 0.5.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ceb4dec276d2d4f97fe52bfad9bfe8d6872007dd
4
- data.tar.gz: 84b9d66207d812a0a086dedab6d8362c2468c3e6
3
+ metadata.gz: 12f1281c4daadee7a741b0d9cf55eb4b1592a42f
4
+ data.tar.gz: a46e8058fa97d38c6a63903994d34954588247c2
5
5
  SHA512:
6
- metadata.gz: 1547d51516853487da839d8ff00fe70be46dacb9689b8f47227cc55fbd5399de83a191ecf4e8e844bf86052d6d2406891b327a68e978b7527fca45da9bff4643
7
- data.tar.gz: 3175e36ca4515ee0e9b1d85301bbdb8cb991b4509330b29efd8a4f3cf294e15f856d07cd8f6ff7e252849175f5a1495d7a9ff46d777afbb87fcabe8267f90acc
6
+ metadata.gz: f1cdbd850515534f5d3c504bc4453a522be6f190276235f92914641c63e2dab8da47d30290b49ea70dc6fa99e45ded4cc404a2c6d16bcaf4e76a489240fe85c7
7
+ data.tar.gz: c78b9a59fe28fedd44a042bee256c9aca38d4beb5cf7960e86aa511ba72ecd2487f8ad49b5c406469496dcedfdcb2ff9ccad37d221375ad9ac03a965e2001643
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## mail_room 0.5.1 ##
2
+
3
+ * Re-idle after 29 minutes to maintain IDLE connection
4
+
5
+ *Douwe Maan <@DouweM>*
6
+
1
7
  ## mail_room 0.5.0 ##
2
8
 
3
9
  * Que delivery method
@@ -4,7 +4,7 @@ module MailRoom
4
4
  # Watch a Mailbox
5
5
  # @author Tony Pitale
6
6
  class MailboxWatcher
7
- attr_accessor :idling_thread
7
+ attr_accessor :idling_thread, :timeout_thread
8
8
 
9
9
  # Watch a new mailbox
10
10
  # @param mailbox [MailRoom::Mailbox] the mailbox to watch
@@ -94,8 +94,20 @@ module MailRoom
94
94
 
95
95
  @idling = true
96
96
 
97
+ self.timeout_thread = Thread.start do
98
+ # The IMAP server will close the connection after 30 minutes of inactivity
99
+ # (which sending IDLE and then nothing technically is), so we re-idle every
100
+ # 29 minutes, as suggested by the spec: https://tools.ietf.org/html/rfc2177
101
+ sleep 29 * 60
102
+
103
+ imap.idle_done if idling?
104
+ end
105
+ timeout_thread.abort_on_exception = true
106
+
97
107
  imap.idle(&idle_handler)
98
108
  ensure
109
+ timeout_thread.kill if timeout_thread
110
+ self.timeout_thread = nil
99
111
  @idling = false
100
112
  end
101
113
 
@@ -104,7 +116,9 @@ module MailRoom
104
116
  return unless idling?
105
117
 
106
118
  imap.idle_done
119
+
107
120
  idling_thread.join
121
+ self.idling_thread = nil
108
122
  end
109
123
 
110
124
  # run the mailbox watcher
@@ -1,4 +1,4 @@
1
1
  module MailRoom
2
2
  # Current version of MailRoom gem
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_room
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Pitale
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-09 00:00:00.000000000 Z
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake