 request        = require 'request'
 
 {secure, daisy, dash, signature, Base} = Bongo
-{uniq} = require 'underscore'
+{throttle} = require 'underscore'
 
 
 module.exports = class SocialChannel extends Base

      id               : Number
      name             : String
      creatorId        : Number
      group            : String
      purpose          : String
      secretKey        : String
      type             : String
      privacy          : String
      createdAt        : Date
      updatedAt        : Date

  JAccount = require '../account'


      if err then callback err
      else callback null, "socialapi.channelsecret.#{secretName}",
        if oldSecretName then "socialapi.channelsecret.#{oldSecretName}"

  @cycleChannel =do->
    cycleChannel = (options, callback=->)->
      JName = require '../name'
      name = @generateChannelName options
      JName.cycleSecretName name, (err, oldSecretName, newSecretName)=>
        return callback err if err
        routingKey = "socialapi.channelsecret.#{oldSecretName}.cycleChannel"
        @emit 'broadcast', routingKey, null
        return callback null
    return throttle cycleChannel, 5000

  cycleChannel:(callback)->
    options =
      groupSlug     : @groupName
      apiChannelType: @typeConstant
      apiChannelName: @name

    @constructor.cycleChannel options, callback

  @fetchActivities = secure (client, options = {}, callback)->
    options.channelId = options.id
