mail_daemon 0.0.10 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mail_daemon/imap/connection.rb +1 -1
- data/lib/mail_daemon/imap/watcher.rb +5 -2
- data/lib/mail_daemon/imap_watcher.rb +7 -2
- data/lib/mail_daemon/version.rb +1 -1
- data/lib/mail_daemon.rb +7 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adeb6c1d708a1c275f706ea1a9b45f336dd1acbb
|
4
|
+
data.tar.gz: 6c90be4d828aff1fe6d15a2d4fa83bcec90758f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd8f2b32bf3f3c38fc3ffc17f19be95fe76df86ece4340ceb86e27079f882e4bdb0a08979072c722e0ad9e1b4a54676d85158c8341ec92bda8f38fb5788e918d
|
7
|
+
data.tar.gz: e0021e2d53f84046ea1460cb15a296edd04c78c4a608bd5dea5590035bbdc9c52e1e4a07f7687e09d11aaca7fd0cba14adc3bcbb2fc983d329d5a1cb237868ae
|
@@ -5,11 +5,10 @@ module MailDaemon
|
|
5
5
|
|
6
6
|
def initialize(options)
|
7
7
|
@options = options
|
8
|
-
|
9
8
|
end
|
10
9
|
|
11
10
|
def start(&block)
|
12
|
-
|
11
|
+
|
13
12
|
@connection = Imap::Connection.new(@options, &block)
|
14
13
|
@connection.login
|
15
14
|
# @thread = Thread.new do
|
@@ -38,6 +37,10 @@ module MailDaemon
|
|
38
37
|
@options[:mailbox]
|
39
38
|
end
|
40
39
|
|
40
|
+
def to_s
|
41
|
+
"#{@options[:account_code]}/#{@options[:username]}"
|
42
|
+
end
|
43
|
+
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -36,12 +36,17 @@ module MailDaemon
|
|
36
36
|
|
37
37
|
watchers = []
|
38
38
|
mysql_client do |mysql|
|
39
|
-
statement = mysql.prepare("
|
39
|
+
statement = mysql.prepare("select ea.*, a.nickname from case_blocks_email_accounts ea join case_blocks_accounts a on a.id = ea.account_id where ea.imap_enabled=1")
|
40
40
|
result = statement.execute()
|
41
41
|
result.each do |row|
|
42
42
|
ssl = row["imap_ssl"]==1 ? {:verify_mode => "none"} : false
|
43
43
|
decrypted_password = Encryption.new.decrypt(row["imap_encrypted_password"])
|
44
|
-
|
44
|
+
begin
|
45
|
+
watcher = Imap::Connection.new({:email => row["imap_username"], :host => row["imap_host"], :port => row["imap_port"], :password => decrypted_password, :ssl => ssl, :start_tls => row["imap_start_tls"]==1, :name => row["imap_folder_name"], :search_command => row["imap_search_command"], :message_count => row["imap_messages_processed"], :last_delivered_at => row["imap_last_delivered_at"], :delivery_method=>"sidekiq", :delivery_options=>{:redis_url => ENV["REDIS_URL"], :queue => "email_handler", :worker=>"EmailHandlerWorker"}})
|
46
|
+
watchers << watcher
|
47
|
+
rescue => e
|
48
|
+
puts "Unable to create IMAP4 connection for #{row['nickname']}/#{row['name']}. #{e.message}"
|
49
|
+
end
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
data/lib/mail_daemon/version.rb
CHANGED
data/lib/mail_daemon.rb
CHANGED
@@ -68,9 +68,13 @@ module MailDaemon
|
|
68
68
|
@threads = []
|
69
69
|
@watchers.each do |watcher|
|
70
70
|
@threads << Thread.new do
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
begin
|
72
|
+
watcher.start do |message|
|
73
|
+
type = message.delete(:type)
|
74
|
+
yield message, type
|
75
|
+
end
|
76
|
+
rescue => e
|
77
|
+
puts "#{watcher}: #{e.message}"
|
74
78
|
end
|
75
79
|
end
|
76
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_daemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- EmergeAdapt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.5.1
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: IMAP account daemon to watch for new mail and to execute a ruby block with
|