 
     return m
 
-  mapChannel:(channels)->
+  mapChannel = (channels)->
     revivedChannels = []
     {SocialChannel} = KD.remote.api
     for channel in channels

        return callback err if err
        return callback null, mapActivities result

  fetchChannels:(options, callback)->
    @getCurrentGroup (group)->
      options.groupName = group.slug
      {SocialChannel} = KD.remote.api
      SocialChannel.fetchChannels options, (err, result)->
        return callback err if err
        return callback null, mapChannel result

  messageApiFunc = (name, rest..., callback)->
    KD.remote.api.SocialMessage[name] rest..., (err, res)->

class SocialApiController extends KDController
  constructor: (options = {}, data) ->
    super options, data

  getCurrentGroup = (callback)->
    groupsController = KD.getSingleton "groupsController"
    groupsController.ready =>
      callback  KD.getSingleton("groupsController").getCurrentGroup()

  fetchChannelActivity = (options, callback)->
    return callback {message: "Channel id is not set for request"} unless options.id
    getCurrentGroup (group)->
      options.groupName = group.slug
      {SocialChannel} = KD.remote.api
      SocialChannel.fetchActivity options, (err, result)->
        return callback err if err
        return callback null, mapActivities result

  fetchGroupActivity = (options, callback)->
    getCurrentGroup (group)->
      return callback {message: "Group doesnt have socialApiChannelId"} unless group.socialApiChannelId
      options.id        = group.socialApiChannelId
      options.groupName = group.slug
