@@ -60,6 +60,9 @@ def add_report(domain, description, falsepositive: bool, response):
6060 except IndexError :
6161 pass
6262
63+ blacklist_status = blacklist_db .fetch ({"blacklisted" : True }).items
64+ blacklist_domain = blacklist_db .fetch ({"domain" : domain }).items
65+
6366 res = requests .get ("https://api.stopmodreposts.org/sites.txt" )
6467
6568 if domain in res .text :
@@ -75,7 +78,7 @@ def add_report(domain, description, falsepositive: bool, response):
7578 "false-positive" : falsepositive
7679 }
7780 }
78- elif len (blacklist_db . fetch ({ "domain" : domain }). items ) != 0 :
81+ elif len (blacklist_status ) != 0 and len ( blacklist_domain ) != 0 :
7982 response .status_code = status .HTTP_400_BAD_REQUEST
8083 return response , {
8184 "detail" : "Failed to report - domain blacklisted" ,
@@ -263,7 +266,13 @@ def get_api_waitlist():
263266
264267@app .get ("/api/v1/blacklist" )
265268def get_api_blacklist ():
266- return {"detail" : "Blacklist (WIP)" }
269+ res = blacklist_db .fetch ({"blacklisted" : True }).items
270+ final = []
271+ for site in res :
272+ final .append ({
273+ "domain" : site ["domain" ]
274+ })
275+ return final
267276
268277@app .post ("/api/v1/report" , status_code = 201 )
269278def post_api_report (response : Response ,
@@ -289,11 +298,16 @@ def post_api_report(response: Response,
289298 """
290299 Reporting endpoint for reposting sites and false-positives
291300 """
301+ if falsepositive :
302+ baseURL = "/forms/falsepositive"
303+ else :
304+ baseURL = "/forms/report"
305+
292306 if captcha is None :
293- return RedirectResponse (url = f"/forms/report ?alert=captcha" , status_code = status .HTTP_303_SEE_OTHER )
307+ return RedirectResponse (url = f"{ baseURL } ?alert=captcha" , status_code = status .HTTP_303_SEE_OTHER )
294308 else :
295309 if verifycaptcha (captcha ) is False :
296- return RedirectResponse (url = f"/forms/report ?alert=captcha" , status_code = status .HTTP_303_SEE_OTHER )
310+ return RedirectResponse (url = f"{ baseURL } ?alert=captcha" , status_code = status .HTTP_303_SEE_OTHER )
297311
298312 if domain == None or description == None :
299313 raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST , detail = "Required form fields missing" )
@@ -306,11 +320,11 @@ def post_api_report(response: Response,
306320 )
307321
308322 if response .status_code == status .HTTP_409_CONFLICT :
309- return RedirectResponse ("/forms/report ?alert=listed" , status_code = status .HTTP_303_SEE_OTHER )
323+ return RedirectResponse (f" { baseURL } ?alert=listed" , status_code = status .HTTP_303_SEE_OTHER )
310324 elif response .status_code == status .HTTP_400_BAD_REQUEST :
311- return RedirectResponse ("/forms/report ?alert=blocked" , status_code = status .HTTP_303_SEE_OTHER )
325+ return RedirectResponse (f" { baseURL } ?alert=blocked" , status_code = status .HTTP_303_SEE_OTHER )
312326 else :
313- return RedirectResponse ("/forms/report ?alert=success" , status_code = status .HTTP_303_SEE_OTHER )
327+ return RedirectResponse (f" { baseURL } ?alert=success" , status_code = status .HTTP_303_SEE_OTHER )
314328
315329
316330if __name__ == "__main__" :
0 commit comments