Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Commit 84a9a0e

Browse files
committed
Notify discord webhook for block list updates
1 parent 99a12dd commit 84a9a0e

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
JWT_SECRET_KEY=
22
ANALYTICS_API_KEY=
33
TURNSTILE_SECRET_KEY=
4-
DISCORD_WEBHOOK_URL=
4+
VERDICTS_DISCORD_WEBHOOK_URL=
5+
REPORTS_DISCORD_WEBHOOK_URL=
56
DB_CONNECTION_STRING=
67
MASTER_USER=
78
MASTER_PASSWORD=

main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ async def get_site(domain) -> list[IllegalSite]:
6767
async def post_site(site: IllegalSite):
6868
sites_collection.insert_one(dict(site))
6969

70+
requests.post(os.getenv("VERDICTS_DISCORD_WEBHOOK_URL"), json={
71+
"content": f"<:smc_flag:1327674316233379840> **A new website has been flagged**\n\nDomain: *{site.get('domain')}*\Reason: *{site.get('reason')}*"
72+
})
73+
7074

7175
@app.put("/sites/{domain}", dependencies=[Depends(auth.access_token_required)])
7276
async def put_site(domain: str, site: IllegalSite):
@@ -77,6 +81,10 @@ async def put_site(domain: str, site: IllegalSite):
7781
async def delete_site(domain: str):
7882
sites_collection.find_one_and_delete({"domain": domain})
7983

84+
requests.post(os.getenv("VERDICTS_DISCORD_WEBHOOK_URL"), json={
85+
"content": f"<:smc_unflag:1327676379331825745> **Website has been unflagged**\n\nDomain: *{domain}*"
86+
})
87+
8088

8189
@app.get("/reports")
8290
async def get_reports() -> list[IllegalSite]:
@@ -125,8 +133,8 @@ async def post_report(site: ReportedIllegalSite):
125133
site_dict["reason"] = hr_reason
126134
reports_collection.insert_one(site_dict)
127135

128-
requests.post(os.getenv("DISCORD_WEBHOOK_URL"), json={
129-
"content": f"**A new website has been reported!**\n\nDomain: *{site_dict.get('domain')}*\nReason: *{site_dict.get('reason')}*"
136+
requests.post(os.getenv("REPORTS_DISCORD_WEBHOOK_URL"), json={
137+
"content": f"<:smc_bell:1327674323007307858> **A new website has been reported**\n\nDomain: *{site_dict.get('domain')}*\nReason: *{site_dict.get('reason')}*"
130138
})
131139
else:
132140
raise HTTPException(409, "Report already exists")

0 commit comments

Comments
 (0)