 
     dash queue, callback
 
-  getName = (delegate)->
+  getName = (delegate) ->
     { nickname, firstName, lastName } = delegate.profile.nickname
 
     name = nickname

        default     : -> new Date

  remove$: permit 'send invitations',
    success: (client, callback=->)->
      @remove callback

  @byCode = (code, callback)->
    @one {code}, callback

  # TODO - generate a better invitation code
  @generateInvitationCode = (email, group)->
    code = crypto.createHmac 'sha1', 'kodingsecret'
    code.update email
    code.update group
    code.digest 'hex'

  accept$: secure (client, callback=->)->
    { delegate } = client.connection
    @accept delegate, callback


    operation = $set : { status: 'accepted' }
    @update operation, callback

  @byCode: (code, callback) ->
    @one {code}, callback

  # TODO - generate a better invitation code
  @generateInvitationCode = (email, group) ->
    code = crypto.createHmac 'sha1', 'kodingsecret'
    code.update email
    code.update group
    code.digest 'hex'

  @create: secure (client, options, callback) ->

    { groupName, delegate } = client.connection
    { invitations }         = options
    groupName             or= 'koding'
    name                    = getName delegate

    queue = invitations.map (invitation) => =>
      { email, firstName, lastName } = invitation

      code = @generateInvitationCode email, groupName

      invite = new JInvitation {
        code
        email
        groupName
        firstName
        lastName
      }

      invite.save (err) ->
        return callback err   if err

        options =
