|
@@ -302,10 +302,10 @@ export default class {
|
|
|
Promise.resolve()
|
|
|
.then(() => {
|
|
|
if (!this.redis) return;
|
|
|
- const twId = cacheId.split(',')[0];
|
|
|
- logger.info(`caching webshot of tweet ${twId} to redis database`);
|
|
|
- this.redis.cacheContent(`webshot/${twId}`, JSON.stringify({msg, text, author}))
|
|
|
- .then(() => this.redis.finishProcess(`webshot/${twId}`));
|
|
|
+ const [twid, rtid] = cacheId.split(',rt:');
|
|
|
+ logger.info(`caching webshot of tweet ${twid} to redis database`);
|
|
|
+ this.redis.cacheContent(`webshot/${twid}`, JSON.stringify({msg, text, author, rtid}))
|
|
|
+ .then(() => this.redis.finishProcess(`webshot/${twid}`));
|
|
|
})
|
|
|
.then(() => sendTweets(cacheId, msg, text, author));
|
|
|
},
|
|
@@ -328,7 +328,8 @@ export default class {
|
|
|
.then(() => this.redis.getContent(`webshot/${id}`))
|
|
|
.then(content => {
|
|
|
if (content === null) throw Error();
|
|
|
- return {id_str: id} as Tweet;
|
|
|
+ const {rtid} = JSON.parse(content);
|
|
|
+ return {id_str: id, retweeted_status: rtid ? {id_str: rtid} : undefined} as Tweet;
|
|
|
}) :
|
|
|
Promise.reject())
|
|
|
.catch(() => this.client.get(endpoint, config))
|
|
@@ -348,7 +349,7 @@ export default class {
|
|
|
...to: IChat[]
|
|
|
) => (id: string, msg: string, text: string, author: string) => {
|
|
|
to.forEach(subscriber => {
|
|
|
- const [twId, rtId] = (/(\d+)(?:,rt:(\d+))?/.exec(id) || []).slice(1);
|
|
|
+ const [twid, rtid] = id.split(',rt:');
|
|
|
const {sourceInfo: source, reportOnSkip, force} = config;
|
|
|
const targetStr = JSON.stringify(subscriber);
|
|
|
const send = () => retryOnError(
|
|
@@ -363,16 +364,16 @@ export default class {
|
|
|
}
|
|
|
).then(() => {
|
|
|
if (this.redis) {
|
|
|
- logger.info(`caching push status of tweet ${rtId ? `${rtId} (RT)` : twId} for ${targetStr}...`);
|
|
|
- return this.redis.cacheForChat(rtId || twId, subscriber);
|
|
|
+ logger.info(`caching push status of tweet ${rtid ? `${rtid} (RTed as ${twid})` : twid} for ${targetStr}...`);
|
|
|
+ return this.redis.cacheForChat(rtid || twid, subscriber);
|
|
|
}
|
|
|
});
|
|
|
- ((this.redis && !force) ? this.redis.isCachedForChat(rtId || twId, subscriber) : Promise.resolve(false))
|
|
|
+ ((this.redis && !force) ? this.redis.isCachedForChat(rtid || twid, subscriber) : Promise.resolve(false))
|
|
|
.then(isCached => {
|
|
|
if (isCached) {
|
|
|
- logger.info(`skipped subscriber ${targetStr} as tweet ${rtId ? `${rtId} (or its RT)` : twId} has been sent already`);
|
|
|
+ logger.info(`skipped subscriber ${targetStr} as tweet ${rtid ? `${rtid} (or its RT)` : twid} has been sent already`);
|
|
|
if (!reportOnSkip) return;
|
|
|
- text = `[最近发送过的推文:${rtId || twId}]`;
|
|
|
+ text = `[最近发送过的推文:${rtid || twid}]`;
|
|
|
msg = author + text;
|
|
|
}
|
|
|
logger.info(`pushing data${source ? ` of ${source}` : ''} to ${targetStr}`);
|