summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2021-10-19 09:05:52 +0200
committerVolpeon <git@volpeon.ink>2021-10-19 09:05:52 +0200
commit4584300d4a8e494231fa66e7c3bd3a0e0efed20d (patch)
tree8ed2a3946391543713018cbcc97cbd26f5cac8ba
parentAvoid duplicate posts (diff)
downloadferalbot-4584300d4a8e494231fa66e7c3bd3a0e0efed20d.tar.gz
feralbot-4584300d4a8e494231fa66e7c3bd3a0e0efed20d.tar.bz2
feralbot-4584300d4a8e494231fa66e7c3bd3a0e0efed20d.zip
Fix dedupe
-rw-r--r--src/api/e621/index.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/api/e621/index.ts b/src/api/e621/index.ts
index 47d5dd1..32b7fc0 100644
--- a/src/api/e621/index.ts
+++ b/src/api/e621/index.ts
@@ -52,7 +52,7 @@ async function loadDedupeDb() {
52 const dd = JSON.parse(d); 52 const dd = JSON.parse(d);
53 53
54 if (dd instanceof Array) { 54 if (dd instanceof Array) {
55 dedupeDb = dd.slice(0, -1 * dedupeMax); 55 dedupeDb = dd.slice(-1 * dedupeMax);
56 } else { 56 } else {
57 dedupeDb = []; 57 dedupeDb = [];
58 } 58 }
@@ -101,6 +101,7 @@ export async function getRandomPost(query: GetPostQuery) {
101 const post = response.posts[postIndex]; 101 const post = response.posts[postIndex];
102 102
103 if (dedupeDb.includes(post.id)) { 103 if (dedupeDb.includes(post.id)) {
104 await new Promise((resolve) => setTimeout(resolve, 1000));
104 return getRandomPost(query); 105 return getRandomPost(query);
105 } 106 }
106 107