|
@@ -276,7 +276,7 @@ class default_1 {
|
|
const offset = lock.threads[currentFeed].offset;
|
|
const offset = lock.threads[currentFeed].offset;
|
|
if (offset > 0)
|
|
if (offset > 0)
|
|
config.since_id = offset;
|
|
config.since_id = offset;
|
|
- const getMore = (gotTweets = []) => this.client.get(endpoint, config, (error, tweets) => {
|
|
|
|
|
|
+ const getMore = (lastTweets = []) => this.client.get(endpoint, config, (error, tweets) => {
|
|
if (error) {
|
|
if (error) {
|
|
if (error instanceof Array && error.length > 0 && error[0].code === 34) {
|
|
if (error instanceof Array && error.length > 0 && error[0].code === 34) {
|
|
logger.warn(`error on fetching tweets for ${currentFeed}: ${JSON.stringify(error)}`);
|
|
logger.warn(`error on fetching tweets for ${currentFeed}: ${JSON.stringify(error)}`);
|
|
@@ -289,10 +289,12 @@ class default_1 {
|
|
logger.error(`unhandled error on fetching tweets for ${currentFeed}: ${JSON.stringify(error)}`);
|
|
logger.error(`unhandled error on fetching tweets for ${currentFeed}: ${JSON.stringify(error)}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (!tweets || tweets.length <= 1)
|
|
|
|
- return resolve(gotTweets);
|
|
|
|
- config.max_id = tweets.slice(-1)[0].id_str;
|
|
|
|
- getMore(gotTweets.concat(tweets));
|
|
|
|
|
|
+ if (!(tweets instanceof Array) || tweets.length === 0)
|
|
|
|
+ return resolve(lastTweets);
|
|
|
|
+ if (offset <= 0)
|
|
|
|
+ return resolve(lastTweets.concat(tweets));
|
|
|
|
+ config.max_id = utils_1.BigNumOps.plus(tweets.slice(-1)[0].id_str, '-1');
|
|
|
|
+ getMore(lastTweets.concat(tweets));
|
|
});
|
|
});
|
|
getMore();
|
|
getMore();
|
|
}
|
|
}
|
|
@@ -301,7 +303,7 @@ class default_1 {
|
|
logger.debug(`api returned ${JSON.stringify(tweets)} for feed ${currentFeed}`);
|
|
logger.debug(`api returned ${JSON.stringify(tweets)} for feed ${currentFeed}`);
|
|
const currentThread = lock.threads[currentFeed];
|
|
const currentThread = lock.threads[currentFeed];
|
|
const updateDate = () => currentThread.updatedAt = new Date().toString();
|
|
const updateDate = () => currentThread.updatedAt = new Date().toString();
|
|
- if (!tweets || tweets.length === 0) {
|
|
|
|
|
|
+ if (tweets.length === 0) {
|
|
updateDate();
|
|
updateDate();
|
|
return;
|
|
return;
|
|
}
|
|
}
|