Cleaned up entrypoint.

This commit is contained in:
2018-05-05 02:27:15 +02:00
parent 9d32450864
commit 804d01d7cf
4 changed files with 110 additions and 85 deletions

View File

@@ -0,0 +1,19 @@
'use strict';
const config = require('config');
const archives = require('./archives.js');
function getArchivePostIds(username, exclude) {
console.log('Searching archives for posts...');
return Promise.all(config.fetch.archives.reddit.map(source => archives[source](username))).then(postIds => postIds.flatten()).then(postIds => {
return exclude ? postIds.filter(postId => !exclude.includes(postId)) : postIds;
}).then(postIds => {
console.log(`Found ${postIds.length} unique archived posts`);
return postIds;
});
};
module.exports = getArchivePostIds;