     template        : template.instantMail
     definition      : "private messages"
 
-prepareAndSendEmail = (notification)->
+sendEmail = (details)->
+  {notification} = details
+  # log "MAIL", flags[details.key].template details
 
-  sendEmail = (details)->
-    {notification} = details
-    # log "MAIL", flags[details.key].template details
+  Emailer.send
+    To        : details.email
+    Subject   : template.commonHeader details
+    HtmlBody  : flags[details.key].template details
+  , (err, status)->
+    log "An error occured: #{err}" if err
+    notification.update $set: status: 'attempted', (err)->
+      console.error err if err
 
-    Emailer.send
-      To        : 'gokmen+testing@koding.com' # details.email
-      Subject   : template.commonHeader details
-      HtmlBody  : flags[details.key].template details
-    , (err, status)->
-      log "An error occured: #{err}" if err
-      notification.update $set: status: 'attempted', (err)->
-        console.error err if err
+fetchSubjectContent = (contents, callback)->
+  {constructorName} = contents.subject
+  constructor       = Base.constructors[constructorName]
+  constructor.one {_id:contents.subject.id}, (err, res)->
+    if err then console.error err
+    callback err, res
 
-  fetchSubjectContent = (contents, callback)->
-    {constructorName} = contents.subject
-    constructor       = Base.constructors[constructorName]
-    constructor.one {_id:contents.subject.id}, (err, res)->
+fetchContent = (content, callback)->
+  {constructorName} = content
+  unless constructorName
+    callback new KodingError 'Action type wrong.'
+  else
+    constructor     = Base.constructors[constructorName]
+    {id}            = content
+    constructor.one {_id:id}, (err, res)->
       if err then console.error err
       callback err, res
 
-  fetchContent = (content, callback)->
-    {constructorName} = content
-    unless constructorName
-      callback new KodingError 'Action type wrong.'
-    else
-      constructor     = Base.constructors[constructorName]
-      {id}            = content
-      constructor.one {_id:id}, (err, res)->
-        if err then console.error err
-        callback err, res
+fetchSubjectContentLink = (content, type, callback)->
 
-  fetchSubjectContentLink = (content, type, callback)->
+  contentTypeLinkMap = (link)->
+    pre = "<a href='#{uri.address}/Activity/#{link}' #{template.linkStyle}>"
 
-    contentTypeLinkMap = (link)->
-      pre = "<a href='#{uri.address}/Activity/#{link}' #{template.linkStyle}>"
+    JReview           : "#{pre}review</a>"
+    JComment          : "#{pre}comment</a>"
+    JOpinion          : "#{pre}opinion</a>"
+    JCodeSnip         : "#{pre}code snippet</a>"
+    JTutorial         : "#{pre}tutorial</a>"
+    JDiscussion       : "#{pre}discussion</a>"
+    JLinkActivity     : "#{pre}link</a>"
+    JStatusUpdate     : "#{pre}status update</a>"
+    JPrivateMessage   : "#{pre}private message</a>"
+    JQuestionActivity : "#{pre}question</a>"
 
-      JReview           : "#{pre}review</a>"
-      JComment          : "#{pre}comment</a>"
-      JOpinion          : "#{pre}opinion</a>"
-      JCodeSnip         : "#{pre}code snippet</a>"
-      JTutorial         : "#{pre}tutorial</a>"
-      JDiscussion       : "#{pre}discussion</a>"
-      JLinkActivity     : "#{pre}link</a>"
-      JStatusUpdate     : "#{pre}status update</a>"
-      JPrivateMessage   : "#{pre}private message</a>"
-      JQuestionActivity : "#{pre}question</a>"
+  if type is 'JPrivateMessage'
+    callback null, "<a href='https://koding.com/Inbox' #{template.linkStyle}>private message</a>"
+  else if content.slug
+    callback null, contentTypeLinkMap(content.slug)[type]
+  else
+    {constructorName} = content.bongo_
+    constructor = Base.constructors[constructorName]
+    constructor.fetchRelated? content._id, (err, relatedContent)->
+      if err then callback err
+      else
+        if relatedContent.slug? or constructorName in ['JReview']
+          callback null, contentTypeLinkMap(relatedContent.slug)[type]
+        else
+          constructor = \
+            Base.constructors[relatedContent.bongo_.constructorName]
+          constructor.fetchRelated? relatedContent._id, (err, content)->
+            if err then callback err
+            else
+              callback null, contentTypeLinkMap(content.slug)[type]
 
-    if type is 'JPrivateMessage'
-      callback null, "<a href='https://koding.com/Inbox' #{template.linkStyle}>private message</a>"
-    else if content.slug
-      callback null, contentTypeLinkMap(content.slug)[type]
-    else
-      {constructorName} = content.bongo_
-      constructor = Base.constructors[constructorName]
-      constructor.fetchRelated? content._id, (err, relatedContent)->
-        if err then callback err
-        else
-          if relatedContent.slug? or constructorName in ['JReview']
-            callback null, contentTypeLinkMap(relatedContent.slug)[type]
-          else
-            constructor = \
-              Base.constructors[relatedContent.bongo_.constructorName]
-            constructor.fetchRelated? relatedContent._id, (err, content)->
-              if err then callback err
-              else
-                callback null, contentTypeLinkMap(content.slug)[type]
+prepareEmail = (notification, cb)->
 
   {JAccount, JEmailNotificationGG} = worker.models
 

                              if err then callback err
                              else
                                details.realContent = content
                                sendEmail details
                          else
                            sendEmail details

job = new CronJob email.notificationCron, ->

  {JEmailNotificationGG} = worker.models
  # log "Checking for waiting queue..."


              else
                details = {sender, receiver, event, email, key, notification}
                if event is 'FollowHappened'
                  cb details
                else
                  # Fetch Subject Content
                  fetchSubjectContent notification.activity, \
