Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

step version

  • Loading branch information...
commit 3f7c70876618078efa59027fb4f7015538ee6a51 1 parent fafc894
Mikolaj Pawlikowski authored August 20, 2012
3  app/models/mailbox.coffee
@@ -78,7 +78,7 @@ Mailbox.prototype.getMail = (boxname, constraints, c) ->
78 78
 
79 79
   # so it looks coool, let's create a connection
80 80
   server = new imap.ImapConnection
81  
-    username: mailbox.login + "_bug"
  81
+    username: mailbox.login
82 82
     password: mailbox.pass
83 83
     host:     mailbox.IMAP_server
84 84
     port:     mailbox.IMAP_port
@@ -131,6 +131,7 @@ Mailbox.prototype.getMail = (boxname, constraints, c) ->
131 131
                 console.log "nothing to download"
132 132
                 mailbox.IMAP_last_sync = new Date().toJSON()
133 133
                 server.logout()
  134
+                callback()
134 135
         
135 136
               # mails to fetch
136 137
               else
36  server.coffee
@@ -14,14 +14,14 @@ if not module.parent
14 14
     
15 15
     @jobs = @kue.createQueue()
16 16
     
17  
-    # @jobs.on "job complete", (id) ->
18  
-    #   Job.get id, (error, job) ->
19  
-    #     return if error
20  
-    #     createCheckJob job.data.mb, 1000 * 60 * 0.5, (error) ->
21  
-    #       return if error
22  
-    #       job.remove (err) ->
23  
-    #         throw err if err
24  
-    #         console.log job.data.title + " #" + job.id + " complete job removed"
  17
+    @jobs.on "job complete", (id) ->
  18
+      Job.get id, (error, job) ->
  19
+        return if error
  20
+        createCheckJob job.data.mb, 1000 * 60 * 0.5, (error) ->
  21
+          return if error
  22
+          job.remove (err) ->
  23
+            throw err if err
  24
+            console.log job.data.title + " #" + job.id + " complete job removed"
25 25
     #       
26 26
     # @jobs.on "job error", (id) ->
27 27
     #   Job.get id, (error, job) ->
@@ -58,9 +58,25 @@ if not module.parent
58 58
     createCheckJobs()
59 59
     
60 60
     @jobs.promote()
  61
+    
  62
+    Step = require "step"
61 63
 
62 64
     # KUE jobs
63 65
     @jobs.process "check mailbox", 1, (job, done) ->
64  
-      console.log job.data.title + " #" + job.id + " job started"
65  
-      (Mailbox job.data.mailbox).getNewMail job.data.num, done
66 66
 
  67
+      Step (prepare = ->
  68
+        console.log job.data.title + " #" + job.id + " job started"
  69
+        this()
  70
+      ),
  71
+      (fetch = (err) ->
  72
+        console.log err if err
  73
+        (Mailbox job.data.mailbox).getNewMail job.data.num, this
  74
+      ), 
  75
+      (showIt = (err) ->
  76
+        if err
  77
+          console.log "KO: " + err
  78
+          done "error"
  79
+        else
  80
+          console.log "OK"
  81
+          done()
  82
+      )

0 notes on commit 3f7c708

Please sign in to comment.
Something went wrong with that request. Please try again.