 _                                       = require 'underscore'
+async                                   = require 'async'
 Bongo                                   = require 'bongo'
 koding                                  = require './../bongo'
 { argv }                                = require 'optimist'


  queue = [

    ->
      { teamAccessCode } = body
      # if we dont have teamaccesscode just continue

      validateTeamInvitation = validateTeamInvitationKallback res, queue
      JTeamInvitation.byCode teamAccessCode, validateTeamInvitation

    ->
      koding.fetchClient clientId, context, (client_) ->

        client = client_


  ]

  async.series queue


validateTeamInvitation = (teamAccessCode, callback) ->

  { JTeamInvitation } = koding.models
  JTeamInvitation.byCode teamAccessCode, (err, invitation) ->
    return callback err.message                     if err
    return callback 'Team Invitation is not found'  if not invitation
    return callback 'Team Invitation is not valid'  if not invitation.isValid()
    return callback null


createGroupKallback = (client, req, res, body) ->
