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,17 +96,19 @@ async function insert_slop(domain: string, path: string) {
} }
} }
const report_url = new URL("/report", API_URL) if(report) {
const request = new Request(report_url, const report_url = new URL("/report", API_URL)
{ const request = new Request(report_url,
method: "POST", {
headers: { method: "POST",
"Content-Type": "application/json", headers: {
"Bearer": get_access_token() "Content-Type": "application/json",
}, "Bearer": get_access_token()
body: JSON.stringify({slop_urls: [new URL(path, "http://"+domain).toString()]}) },
}) body: JSON.stringify({slop_urls: [new URL(path, "http://"+domain).toString()]})
fetch(request) })
fetch(request)
}
} }
async function check_local_slop(url: string) { async function check_local_slop(url: string) {
@@ -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
} }