add a boolean to prevent re-reporting links that are inserted into the indexeddb from a check response

This commit is contained in:
Jack Case
2025-11-01 20:01:10 +00:00
parent c4c0119f66
commit 3753d103e4

View File

@@ -63,7 +63,7 @@ async function get_slop_store(readwrite: boolean) {
return await slop_store_promise return await slop_store_promise
} }
async function insert_slop(domain: string, path: string) { async function insert_slop(domain: string, path: string, report: boolean = true) {
let db let db
const db_request = window.indexedDB.open("SlopDB", 1) const db_request = window.indexedDB.open("SlopDB", 1)
@@ -96,6 +96,7 @@ async function insert_slop(domain: string, path: string) {
} }
} }
if(report) {
const report_url = new URL("/report", API_URL) const report_url = new URL("/report", API_URL)
const request = new Request(report_url, const request = new Request(report_url,
{ {
@@ -108,6 +109,7 @@ async function insert_slop(domain: string, path: string) {
}) })
fetch(request) fetch(request)
} }
}
async function check_local_slop(url: string) { async function check_local_slop(url: string) {
const slop_url = new URL(url) const slop_url = new URL(url)
@@ -141,7 +143,7 @@ async function check_remote_slop(urls: string[]) {
const request = new Request(check_url, {method: "POST", headers: { "Content-Type": "application/json", "Bearer": get_access_token() }, body: JSON.stringify({slop_urls: urls})}) const request = new Request(check_url, {method: "POST", headers: { "Content-Type": "application/json", "Bearer": get_access_token() }, body: JSON.stringify({slop_urls: urls})})
const response = await fetch(request) const response = await fetch(request)
let domain_objects = await response.json() let domain_objects = await response.json()
domain_objects.forEach((domain: any) => {insert_slop(domain.domain_name, "/")}) domain_objects.forEach((domain: any) => {insert_slop(domain.domain_name, "/", false)})
return domain_objects return domain_objects
} }