mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +00:00
If a tweet doesn’t exist, provide a way to explicitly mark it as such in backup.
This commit is contained in:
parent
53a8378bd3
commit
92a982eeb8
@ -4,6 +4,7 @@ const { resolve } = require('./resolve');
|
||||
const log = require('fancy-log');
|
||||
const tweetparse = require('./lib/tweetparse');
|
||||
const Twitter = require('twitter-lite');
|
||||
const { hasOwn } = require('./lib/util');
|
||||
|
||||
|
||||
module.exports = exports = async function tweets (pages) {
|
||||
@ -46,12 +47,18 @@ module.exports = exports = async function tweets (pages) {
|
||||
|
||||
const absent = difference(tweetsRequested, loaded);
|
||||
for (const id of absent) {
|
||||
if (twitterBackup[id]) {
|
||||
log('Pulled tweet from backup ' + id);
|
||||
twitterCache[id] = tweetparse(twitterBackup[id]);
|
||||
if (!hasOwn(twitterBackup, id)) {
|
||||
log.error('Could not find tweet ' + id);
|
||||
continue;
|
||||
}
|
||||
log.error('Could not find tweet ' + id);
|
||||
const tweet = twitterBackup[id];
|
||||
|
||||
if (tweet) {
|
||||
log('Pulled tweet from backup ' + id);
|
||||
twitterCache[id] = tweetparse(twitterBackup[id]);
|
||||
} else {
|
||||
twitterCache[id] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,11 +67,12 @@ module.exports = exports = async function tweets (pages) {
|
||||
const twitterMedia = [];
|
||||
|
||||
function attachTweet (dict, tweetid) {
|
||||
const tweet = twitterCache[tweetid];
|
||||
if (!tweet) {
|
||||
if (!hasOwn(twitterCache, tweetid) && twitterBackup[tweetid]) {
|
||||
log.error(`Tweet ${tweetid} is missing from the cache.`);
|
||||
return;
|
||||
}
|
||||
const tweet = twitterCache[tweetid];
|
||||
if (!tweet) return;
|
||||
dict[tweetid] = tweet;
|
||||
twitterMedia.push( ...tweet.media );
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"1215734983840673793": false,
|
||||
"1228717614630940672": {
|
||||
"created_at": "Sat Feb 15 16:28:02 +0000 2020",
|
||||
"id": 1228717614630940700,
|
||||
|
Loading…
x
Reference in New Issue
Block a user