komentify / meteor-comments-ui

Simple templates for comment functionality in your Meteor App
MIT License
76 stars 40 forks source link

Media Analyzer Method Call Error #69

Closed ritchieng closed 8 years ago

ritchieng commented 8 years ago

Hi,

This package is amazing and works well in all cases until I follow your documentation on implementing image analyzers.

comments.js

Comments.config({
    mediaAnalyzers: [
        Comments.analyzers.image,
        Comments.analyzers.youtube,
        myAnalyzer
    ]
});

const myAnalyzer = {
    name: 'twitter',
    getMediaFromContent(content) {}, // return a string
    getMarkup(mediaContent) {}, // return a string
};

Error in console

Exception while simulating the effect of invoking 'comments/add' TypeError: Cannot read property 'getMediaFromContent' of undefined(…)

Error invoking Method 'comments/add': Internal server error [500]

Error in terminal

I20160403-14:35:22.882(2)? Exception while invoking method 'comments/add' { stack: 'TypeError: Cannot call method \'getMediaFromContent\' of undefined\n    at lib/services/media.js:9:41\n    at Array.forEach (native)\n    at Function._.each._.forEach (packages/underscore/underscore.js:105:1)\n    at Object.mediaService.getMediaFromContent (lib/services/media.js:8:11)\n    at [object Object].Meteor.methods.comments/add (lib/collections/methods/comments.js:78:31)\n    at [object Object].methodMap.(anonymous function) (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:164:1)\n    at maybeAuditArgumentChecks (livedata_server.js:1698:12)\n    at livedata_server.js:708:19\n    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)\n    at livedata_server.js:706:40\n    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)\n    at livedata_server.js:704:46\n    at tryCallTwo (/Users/ritchieng/.meteor/packages/promise/.0.5.1.8idxpg++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)\n    at doResolve (/Users/ritchieng/.meteor/packages/promise/.0.5.1.8idxpg++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/lib/core.js:171:13)\n    at new Promise (/Users/ritchieng/.meteor/packages/promise/.0.5.1.8idxpg++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/lib/core.js:65:3)\n    at [object Object]._.extend.protocol_handlers.method (livedata_server.js:678:23)',
I20160403-14:35:22.883(2)?   source: 'method' }
matteodem commented 8 years ago

This is because you are not defining myAnalyzer before using it in the mediaAnalyzers array.