navilocal 1.1.6 → 1.1.7
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 +4 -4
- data/application/ui/navi/main_runner.rb +10 -152
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cd6662bfee0b47c130fabceb2d28c72c0c027d1fde77db435d719bf063556f9
|
4
|
+
data.tar.gz: 81108516790458543b88124660c1b9a4a4d5bb2ba819064382143f1f280df7d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a910d7c8e566490d9663019cf1a13b1660a2bcc0be9137ab20c690c6283a1ec9f3282587a03b41ba621a9fbd3b2be971ad3d4cee948ccb36d8767ff396154e36
|
7
|
+
data.tar.gz: f241323fc09720c72e8b204ed702c0f4033bc4d71f961f271aa2ca70c89b811f5077a04e4003e911f36e356506d28954289f20c2d9af83b0c8dadcdf2b424a6e
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative '../../lib/common_functions'
|
2
|
-
require '
|
2
|
+
require 'navi_email_sync'
|
3
3
|
require 'httparty'
|
4
4
|
require 'base64'
|
5
5
|
|
@@ -109,7 +109,7 @@ module NaviClientInstaller
|
|
109
109
|
@spinner_indicator.active = true
|
110
110
|
@refresh_btn.sensitive = true
|
111
111
|
@stop_btn.sensitive = true
|
112
|
-
|
112
|
+
start_fetching
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|
@@ -130,150 +130,8 @@ module NaviClientInstaller
|
|
130
130
|
|
131
131
|
end
|
132
132
|
|
133
|
-
|
134
133
|
def start_fetching
|
135
134
|
|
136
|
-
@client = NaviClient::Local.new ""
|
137
|
-
@client.set_token "Token: #{@token}##{@settings.username}"
|
138
|
-
@logger = CustomLogger.new @log_display.buffer, @iter_log, @client.logger
|
139
|
-
@client.override_logger @logger
|
140
|
-
|
141
|
-
#logging to loggly
|
142
|
-
logToLoggly = true
|
143
|
-
if logToLoggly
|
144
|
-
@client.setupLoggly("navi-client")
|
145
|
-
end
|
146
|
-
|
147
|
-
@logger.debug "Running the process.."
|
148
|
-
@logger.debug "Connecting to imap server with your local config."
|
149
|
-
|
150
|
-
@notifier.label = "Configuring the system.."
|
151
|
-
begin
|
152
|
-
|
153
|
-
@imap = @client.imap_connection(@settings.provider, @settings.username, @settings.password, false)
|
154
|
-
|
155
|
-
if @client.errors.nil?
|
156
|
-
|
157
|
-
@logger.debug "Complete. OK..."
|
158
|
-
|
159
|
-
filenames = []
|
160
|
-
dateStarted = DateTime.now
|
161
|
-
@logger.debug "Syncing started at #{dateStarted}"
|
162
|
-
|
163
|
-
sendEmailCompletedEvent = true
|
164
|
-
folder = "Inbox"
|
165
|
-
|
166
|
-
#this block of code is repeated. Need to change in navi_client gem for that
|
167
|
-
@imap.examine folder
|
168
|
-
total = @imap.uid_search(['ALL']).size
|
169
|
-
downloaded = @client.getMessageUUIds("#{@settings.download_path}#{@settings.username}/meta/").size
|
170
|
-
downloaded = downloaded - 2 if downloaded > 1
|
171
|
-
downloaded = [downloaded, total].min
|
172
|
-
|
173
|
-
@email_indicator.label = "#{downloaded}/#{total}"
|
174
|
-
@client.logToLoggly({event:"EMAIL_SYNC_STARTED", env: ENV['env'], storage: "local", email: @settings.username, total_email: total, already_downloaded: downloaded})
|
175
|
-
|
176
|
-
# start_naviai
|
177
|
-
@notifier.label = "Starting up.."
|
178
|
-
@logger.debug "Starting the system"
|
179
|
-
start_naviai
|
180
|
-
@notifier.label = "Checking for previous failures.."
|
181
|
-
@logger.debug "Parsing previously fetched emails"
|
182
|
-
@client.parse_prev_failed_emails
|
183
|
-
@logger.debug "Complete. OK..."
|
184
|
-
# stop_naviai
|
185
|
-
@notifier.label = "Fetching emails..."
|
186
|
-
stamp = (Time.now.to_f * 1000).to_s
|
187
|
-
@client.retrieve_emails(@imap, ['ALL'], folder) do |mail, index, isLast, id|
|
188
|
-
|
189
|
-
@logger.debug "processing email##{index + 1} with id #{mail.__id__.to_s} and uuid #{id}"
|
190
|
-
|
191
|
-
filenames << @client.process_email(mail, id, stamp)
|
192
|
-
downloaded+=1
|
193
|
-
downloaded = [downloaded, total].min
|
194
|
-
@email_indicator.label = "#{downloaded}/#{total}"
|
195
|
-
|
196
|
-
@logger.debug "processing Complete. OK..."
|
197
|
-
|
198
|
-
if filenames.size == 50 || isLast
|
199
|
-
sendEmailCompletedEvent = !sendEmailCompletedEvent
|
200
|
-
|
201
|
-
@logger.debug "Sending Bulk Request for #{isLast ? filenames.size : 50} emails to Navi AI."
|
202
|
-
@notifier.label = "Parsing the emails..."
|
203
|
-
|
204
|
-
start_naviai
|
205
|
-
@client.send_request(filenames, stamp, is_last: isLast)
|
206
|
-
# stop_naviai
|
207
|
-
|
208
|
-
@logger.debug "Complete Ok... continue email sync"
|
209
|
-
@notifier.label = "Fetching emails..."
|
210
|
-
# verify
|
211
|
-
filenames = []
|
212
|
-
if sendEmailCompletedEvent && !isLast
|
213
|
-
@client.logToLoggly({event:"EMAIL_SYNC_IN_PROGRESS", env: ENV['env'], storage: "local", email: @settings.username, emailCount: index + 1})
|
214
|
-
# exit
|
215
|
-
elsif isLast
|
216
|
-
|
217
|
-
dateEnded = DateTime.now
|
218
|
-
totalTimeInSecs = (dateEnded - dateStarted) * 24 * 60 * 60
|
219
|
-
|
220
|
-
@client.logToLoggly({event:"EMAIL_SYNC_FINISHED", env: ENV['env'], storage: "local", email: @settings.username, emailCount: index + 1, time_elapsed: totalTimeInSecs.to_f.round(2), total_email: total, already_downloaded: downloaded})
|
221
|
-
@logger.debug "#{index + 1} emails from the #{folder} has been downloaded. OK"
|
222
|
-
@logger.debug "started: #{dateStarted.to_s} , ended: #{dateEnded.to_s}, Total time: #{totalTimeInSecs.to_f.round(2)} secs"
|
223
|
-
end
|
224
|
-
|
225
|
-
stamp = (Time.now.to_f * 1000).to_s
|
226
|
-
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
@logger.debug "All emails sync and parse completed."
|
231
|
-
|
232
|
-
@notifier.label = "Finalizing..."
|
233
|
-
|
234
|
-
callback = Proc.new do |mail, index, id, complete|
|
235
|
-
# complete = args.first || false
|
236
|
-
|
237
|
-
if complete
|
238
|
-
downloaded+=1
|
239
|
-
@logger.debug "processing Complete. OK..."
|
240
|
-
else
|
241
|
-
@notifier.label = "Fetching emails..."
|
242
|
-
@logger.debug "processing email##{index + 1} with id #{mail.__id__.to_s} and uuid #{id}"
|
243
|
-
total+=1
|
244
|
-
end
|
245
|
-
downloaded = [downloaded, total].min
|
246
|
-
@email_indicator.label = "#{downloaded}/#{total}"
|
247
|
-
|
248
|
-
end
|
249
|
-
|
250
|
-
naviai_control = Proc.new do |start|
|
251
|
-
if start
|
252
|
-
@notifier.label = "Parsing the emails..."
|
253
|
-
start_naviai
|
254
|
-
else
|
255
|
-
# stop_naviai
|
256
|
-
@logger.debug "Waiting new mails (IDLE loop)..."
|
257
|
-
@notifier.label = "Waiting for the new emails.."
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
@notifier.label = "Waiting for the new emails.."
|
262
|
-
@client.idle_loop(['UNSEEN'], folder, @settings.provider, @settings.username, @settings.password, callback, naviai_control)
|
263
|
-
|
264
|
-
else
|
265
|
-
@logger.debug "Failed to connect with your email. Please recheck the configuration."
|
266
|
-
end
|
267
|
-
rescue => e
|
268
|
-
@logger.debug "#{e.message}"
|
269
|
-
restart_process false
|
270
|
-
end
|
271
|
-
|
272
|
-
end
|
273
|
-
|
274
|
-
|
275
|
-
def start_fetchings
|
276
|
-
|
277
135
|
@logger = CustomLogger.new @log_display.buffer, @iter_log
|
278
136
|
@logger.debug "Running the process.."
|
279
137
|
@logger.debug "Initializing the client."
|
@@ -281,13 +139,13 @@ module NaviClientInstaller
|
|
281
139
|
begin
|
282
140
|
|
283
141
|
if @settings.method == "imap"
|
284
|
-
@client =
|
142
|
+
@client = NaviEmailSync::ImapApi.new @settings.method
|
285
143
|
@logger.set_custom_logger @client.logger
|
286
144
|
@client.override_logger @logger
|
287
145
|
@controller = @client.imap_connection(@settings.provider, @settings.username, @settings.password, false)
|
288
146
|
@controller = nil unless @client.errors.nil?
|
289
147
|
else
|
290
|
-
@client =
|
148
|
+
@client = NaviEmailSync::GmailApi.new @settings.method
|
291
149
|
@logger.set_custom_logger @client.logger
|
292
150
|
@client.override_logger @logger
|
293
151
|
@controller = @client.init(NaviClientInstaller::Settings::GMAIL_CLIENT_PATH, NaviClientInstaller::Settings::GMAIL_TOKEN_PATH, @settings.username)
|
@@ -316,7 +174,7 @@ module NaviClientInstaller
|
|
316
174
|
|
317
175
|
downloaded_mails = @client.downloaded
|
318
176
|
@email_indicator.label = "#{downloaded_mails}/#{@client.total_emails}"
|
319
|
-
@client.logToLoggly({event:"EMAIL_SYNC_STARTED", env: ENV['env'], storage: "local", email: @settings.username, total_email:
|
177
|
+
@client.logToLoggly({event:"EMAIL_SYNC_STARTED", env: ENV['env'], storage: "local", email: @settings.username, total_email: @client.total_emails, already_downloaded: @client.downloaded})
|
320
178
|
|
321
179
|
@notifier.label = "Starting up.."
|
322
180
|
@logger.debug "Starting the system"
|
@@ -379,15 +237,15 @@ module NaviClientInstaller
|
|
379
237
|
# complete = args.first || false
|
380
238
|
|
381
239
|
if complete
|
382
|
-
|
240
|
+
downloaded_mails+=1
|
383
241
|
@logger.debug "processing Complete. OK..."
|
384
242
|
else
|
385
243
|
@notifier.label = "Fetching emails..."
|
386
|
-
@logger.debug "processing email##{index + 1} with id #{
|
387
|
-
|
244
|
+
@logger.debug "processing email##{index + 1} with id #{id}"
|
245
|
+
@client.total_emails+=1
|
388
246
|
end
|
389
|
-
|
390
|
-
@email_indicator.label = "#{
|
247
|
+
downloaded_mails = [downloaded_mails, @client.total_emails].min
|
248
|
+
@email_indicator.label = "#{downloaded_mails}/#{@client.total_emails}"
|
391
249
|
|
392
250
|
end
|
393
251
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navilocal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Msanjib
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.11.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: navi_email_sync
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|