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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cd812263f7c714bdce09da22ccc21d608f81a53
4
- data.tar.gz: 468f8a17341b9e87ccb5d2df0713318f4ec74130
3
+ metadata.gz: adeb6c1d708a1c275f706ea1a9b45f336dd1acbb
4
+ data.tar.gz: 6c90be4d828aff1fe6d15a2d4fa83bcec90758f8
5
5
  SHA512:
6
- metadata.gz: f659ab1b7ea3f773d1a96d2de4004515c6b129310ffcc189d3e938d5cfaac37856f9726ad814a6e97ee048839168a4053625916419d58331e68592ba79222af6
7
- data.tar.gz: 7568022856846dcaec67ad2a54d8d7762127e0ffeee5565ece2724c90ddfb6caa87f0b7ab8f5893a0d71746a191aacfccabba2abbf809a3786bd9144365ad81c
6
+ metadata.gz: fd8f2b32bf3f3c38fc3ffc17f19be95fe76df86ece4340ceb86e27079f882e4bdb0a08979072c722e0ad9e1b4a54676d85158c8341ec92bda8f38fb5788e918d
7
+ data.tar.gz: e0021e2d53f84046ea1460cb15a296edd04c78c4a608bd5dea5590035bbdc9c52e1e4a07f7687e09d11aaca7fd0cba14adc3bcbb2fc983d329d5a1cb237868ae
@@ -131,7 +131,7 @@ module MailDaemon
131
131
  puts e.message
132
132
  end
133
133
  set_status(LOGGING_OFF)
134
- @imap.logout unless @imap.disconnected?
134
+ @imap.logout unless imap.disconnected?
135
135
  set_status(LOGGED_OFF)
136
136
  end
137
137
 
@@ -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("SELECT * FROM case_blocks_email_accounts where imap_enabled=1")
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
- watchers << 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"}})
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
 
@@ -1,3 +1,3 @@
1
1
  module MailDaemon
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.12"
3
3
  end
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
- watcher.start do |message|
72
- type = message.delete(:type)
73
- yield message, type
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.10
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: 2016-07-15 00:00:00.000000000 Z
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.4.5.1
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