Fix webhook?
Browse files- backend/app.py +9 -5
backend/app.py
CHANGED
|
@@ -111,7 +111,6 @@ async def init_db():
|
|
| 111 |
{
|
| 112 |
"sql": "CREATE TABLE IF NOT EXISTS pi_scans (post_id TEXT PRIMARY KEY, url TEXT, exif_type INTEGER)"
|
| 113 |
},
|
| 114 |
-
{"sql": "DELETE FROM pi_searches"},
|
| 115 |
]
|
| 116 |
)
|
| 117 |
|
|
@@ -121,10 +120,15 @@ async def discord_notify(msg):
|
|
| 121 |
print("WARN: DISCORD_WEBHOOK_URL not set, skipping notify")
|
| 122 |
return
|
| 123 |
try:
|
| 124 |
-
async with
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
except Exception as e:
|
| 129 |
print(f"Discord webhook error: {repr(e)}")
|
| 130 |
|
|
|
|
| 111 |
{
|
| 112 |
"sql": "CREATE TABLE IF NOT EXISTS pi_scans (post_id TEXT PRIMARY KEY, url TEXT, exif_type INTEGER)"
|
| 113 |
},
|
|
|
|
| 114 |
]
|
| 115 |
)
|
| 116 |
|
|
|
|
| 120 |
print("WARN: DISCORD_WEBHOOK_URL not set, skipping notify")
|
| 121 |
return
|
| 122 |
try:
|
| 123 |
+
async with aiohttp.ClientSession() as session:
|
| 124 |
+
async with session.post(
|
| 125 |
+
DISCORD_WEBHOOK_URL.rstrip("/"),
|
| 126 |
+
json={"content": msg},
|
| 127 |
+
timeout=aiohttp.ClientTimeout(total=15),
|
| 128 |
+
) as r:
|
| 129 |
+
if r.status >= 400:
|
| 130 |
+
body = await r.text()
|
| 131 |
+
print(f"Discord webhook failed ({r.status}): {body}")
|
| 132 |
except Exception as e:
|
| 133 |
print(f"Discord webhook error: {repr(e)}")
|
| 134 |
|