diff --git a/storage/amnesia.js b/storage/amnesia.js index f068a5e75..bd414b8fb 100644 --- a/storage/amnesia.js +++ b/storage/amnesia.js @@ -18,6 +18,7 @@ module.exports.create = function(conf, cb){ var db=[], index=0; + cb({ message: function(channelName, content, cb){ var val = { @@ -27,17 +28,18 @@ module.exports.create = function(conf, cb){ time: new Date().getTime(), }; db.push(val); - cb(); + if (cb) { cb(); } }, - getMessages: function(channelName, cb){ + getMessages: function(channelName, handler, cb){ db.sort(function(a,b){ return a.id - b.id; }); db.filter(function(val){ return val.chan === channelName; }).forEach(function(doc){ - cb(doc.msg); + handler(doc.msg); }); + if (cb) { cb(); } }, }); };