mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 15:26: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 log = require('fancy-log');
|
||||||
const tweetparse = require('./lib/tweetparse');
|
const tweetparse = require('./lib/tweetparse');
|
||||||
const Twitter = require('twitter-lite');
|
const Twitter = require('twitter-lite');
|
||||||
|
const { hasOwn } = require('./lib/util');
|
||||||
|
|
||||||
|
|
||||||
module.exports = exports = async function tweets (pages) {
|
module.exports = exports = async function tweets (pages) {
|
||||||
@ -46,12 +47,18 @@ module.exports = exports = async function tweets (pages) {
|
|||||||
|
|
||||||
const absent = difference(tweetsRequested, loaded);
|
const absent = difference(tweetsRequested, loaded);
|
||||||
for (const id of absent) {
|
for (const id of absent) {
|
||||||
if (twitterBackup[id]) {
|
if (!hasOwn(twitterBackup, id)) {
|
||||||
log('Pulled tweet from backup ' + id);
|
log.error('Could not find tweet ' + id);
|
||||||
twitterCache[id] = tweetparse(twitterBackup[id]);
|
|
||||||
continue;
|
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 = [];
|
const twitterMedia = [];
|
||||||
|
|
||||||
function attachTweet (dict, tweetid) {
|
function attachTweet (dict, tweetid) {
|
||||||
const tweet = twitterCache[tweetid];
|
if (!hasOwn(twitterCache, tweetid) && twitterBackup[tweetid]) {
|
||||||
if (!tweet) {
|
|
||||||
log.error(`Tweet ${tweetid} is missing from the cache.`);
|
log.error(`Tweet ${tweetid} is missing from the cache.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const tweet = twitterCache[tweetid];
|
||||||
|
if (!tweet) return;
|
||||||
dict[tweetid] = tweet;
|
dict[tweetid] = tweet;
|
||||||
twitterMedia.push( ...tweet.media );
|
twitterMedia.push( ...tweet.media );
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"1215734983840673793": false,
|
||||||
"1228717614630940672": {
|
"1228717614630940672": {
|
||||||
"created_at": "Sat Feb 15 16:28:02 +0000 2020",
|
"created_at": "Sat Feb 15 16:28:02 +0000 2020",
|
||||||
"id": 1228717614630940700,
|
"id": 1228717614630940700,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user