|
|
|
@ -595,7 +595,9 @@ module.exports.create = function (cfg, cb) {
|
|
|
|
|
const start = (beforeHash) ? 0 : offset;
|
|
|
|
|
store.readMessagesBin(channelName, start, (msgObj, readMore, abort) => {
|
|
|
|
|
if (beforeHash && msgObj.offset >= offset) { return void abort(); }
|
|
|
|
|
handler(tryParse(msgObj.buff.toString('utf8')), readMore);
|
|
|
|
|
var parsed = tryParse(msgObj.buff.toString('utf8'));
|
|
|
|
|
if (!parsed) { return void readMore(); }
|
|
|
|
|
handler(parsed, readMore);
|
|
|
|
|
}, waitFor(function (err) {
|
|
|
|
|
return void cb(err);
|
|
|
|
|
}));
|
|
|
|
@ -747,7 +749,6 @@ module.exports.create = function (cfg, cb) {
|
|
|
|
|
|
|
|
|
|
// TODO compute lastKnownHash in a manner such that it will always skip past the metadata line?
|
|
|
|
|
getHistoryAsync(channelName, lastKnownHash, false, (msg, readMore) => {
|
|
|
|
|
if (!msg) { return; } // XXX
|
|
|
|
|
msgCount++;
|
|
|
|
|
// avoid sending the metadata message a second time
|
|
|
|
|
if (isMetadataMessage(msg) && metadata_cache[channelName]) { return readMore(); }
|
|
|
|
@ -866,7 +867,6 @@ module.exports.create = function (cfg, cb) {
|
|
|
|
|
// FIXME should we send metadata here too?
|
|
|
|
|
// none of the clientside code which uses this API needs metadata, but it won't hurt to send it (2019-08-22)
|
|
|
|
|
return void getHistoryAsync(parsed[1], -1, false, (msg, readMore) => {
|
|
|
|
|
if (!msg) { return; }
|
|
|
|
|
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(['FULL_HISTORY', msg])], readMore);
|
|
|
|
|
}, (err) => {
|
|
|
|
|
let parsedMsg = ['FULL_HISTORY_END', parsed[1]];
|
|
|
|
|