 ApiError       = require './error'
 
 {secure, daisy, dash, signature, Base} = Bongo
-{uniq} = require 'underscore'
+{uniq, extend} = require 'underscore'
 
 
 module.exports = class SocialMessage extends Base

          (signature Object, Function)
        fetch  :
          (signature Object, Function)

    schema          :
      id               : Number

          return callback null, yes
        fn client, callback


  cachedEmbedlyResult = {}

  @fetchDataFromEmbedly = (urls, options, callback) ->

    if result = cachedEmbedlyResult[urls]
      return callback null, result

    urls = [urls]  unless Array.isArray urls

    Embedly    = require "embedly"
    { apiKey } = KONFIG.embedly

    new Embedly key: apiKey, (err, api) ->

      return callback err  if err

      options    = extend options,
        urls     : urls
        maxWidth : 150

      api.extract options, (err, result) ->
        return callback err, result  if err

        cachedEmbedlyResult[urls] = result
        callback err, result


