Skip to content

Commit 6e7170a

Browse files
committed
Workaround for flimsy API
1 parent d76aa0d commit 6e7170a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/forum.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ when not defined(skipStopForumSpamCheck):
255255
resp = client.get("https://api.stopforumspam.org/api?emailhash=" & c.email.getMd5 & "&json")
256256
if resp.code == Http200:
257257
let jresp = resp.body.parseJson
258-
if jresp["success"].num == 1 and jresp["emailhash"].hasKey("confidence") and jresp["emailhash"]["confidence"].str.parseFloat > 0.0:
258+
if jresp["success"].num == 1 and jresp["emailhash"].hasKey("confidence") and (
259+
(jresp["emailhash"]["confidence"].kind == JString and jresp["emailhash"]["confidence"].str.parseFloat > 0.0) or
260+
(jresp["emailhash"]["confidence"].kind == JInt and jresp["emailhash"]["confidence"].num > 0.0) or
261+
(jresp["emailhash"]["confidence"].kind == JFloat and jresp["emailhash"]["confidence"].fnum > 0.0)):
259262
exec(
260263
db,
261264
sql"update person set status = ? where name = ?;",

0 commit comments

Comments
 (0)