Skip to content

Commit d76aa0d

Browse files
committed
Let forum posts be created before user is marked as spammer
1 parent 22333a9 commit d76aa0d

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/forum.nim

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -553,18 +553,6 @@ proc executeReply(c: TForumData, threadId: int, content: string,
553553
if rateLimitCheck(c):
554554
raise newForumError("You're posting too fast!")
555555

556-
when not defined(skipStopForumSpamCheck):
557-
if stopForumSpamCheck(c):
558-
raise newForumError("Your account has been marked by https://www.stopforumspam.com/. If you believe this is a mistake please contact a moderator. " & supportUrl)
559-
560-
when not defined(skipSpamHeuristics):
561-
if spamHeuristicsCheck(c, content):
562-
raise newForumError("Your account has been automatically marked as spam. If you believe this is a mistake please contact a moderator. " & supportUrl)
563-
564-
when defined(wordlistSpamCutoff):
565-
if wordlistSpamCheck(c, content):
566-
raise newForumError("Your account has been automatically marked as spam. If you believe this is a mistake please contact a moderator. " & supportUrl)
567-
568556
if content.strip().len == 0:
569557
raise newForumError("Message cannot be empty")
570558

@@ -606,6 +594,18 @@ proc executeReply(c: TForumData, threadId: int, content: string,
606594
retID.int, content
607595
)
608596

597+
when not defined(skipStopForumSpamCheck):
598+
if stopForumSpamCheck(c):
599+
raise newForumError("Your account has been marked by https://www.stopforumspam.com/. If you believe this is a mistake please contact a moderator. " & supportUrl)
600+
601+
when not defined(skipSpamHeuristics):
602+
if spamHeuristicsCheck(c, content):
603+
raise newForumError("Your account has been automatically marked as spam. If you believe this is a mistake please contact a moderator. " & supportUrl)
604+
605+
when defined(wordlistSpamCutoff):
606+
if wordlistSpamCheck(c, content):
607+
raise newForumError("Your account has been automatically marked as spam. If you believe this is a mistake please contact a moderator. " & supportUrl)
608+
609609
exec(db, sql"update thread set modified = DATETIME('now') where id = ?",
610610
$threadId)
611611

@@ -699,6 +699,16 @@ proc executeNewThread(c: TForumData, subject, msg, categoryID: string): (int64,
699699
if rateLimitCheck(c):
700700
raise newForumError("You're posting too fast!")
701701

702+
result[0] = tryInsertID(db, query, subject, categoryID).int
703+
if result[0] < 0:
704+
raise newForumError("Subject already exists", @["subject"])
705+
706+
discard tryExec(db, crud(crCreate, "thread_fts", "id", "name"),
707+
result[0], subject)
708+
result[1] = executeReply(c, result[0].int, msg, none[int]())
709+
discard tryExec(db, sql"insert into post_fts(post_fts) values('optimize')")
710+
discard tryExec(db, sql"insert into post_fts(thread_fts) values('optimize')")
711+
702712
when not defined(skipStopForumSpamCheck):
703713
if stopForumSpamCheck(c):
704714
raise newForumError("Your account has been marked by https://www.stopforumspam.com/. If you believe this is a mistake please contact a moderator. " & supportUrl)
@@ -711,16 +721,6 @@ proc executeNewThread(c: TForumData, subject, msg, categoryID: string): (int64,
711721
if wordlistSpamCheck(c, msg):
712722
raise newForumError("Your account has been automatically marked as spam. If you believe this is a mistake please contact a moderator. " & supportUrl)
713723

714-
result[0] = tryInsertID(db, query, subject, categoryID).int
715-
if result[0] < 0:
716-
raise newForumError("Subject already exists", @["subject"])
717-
718-
discard tryExec(db, crud(crCreate, "thread_fts", "id", "name"),
719-
result[0], subject)
720-
result[1] = executeReply(c, result[0].int, msg, none[int]())
721-
discard tryExec(db, sql"insert into post_fts(post_fts) values('optimize')")
722-
discard tryExec(db, sql"insert into post_fts(thread_fts) values('optimize')")
723-
724724
proc executeLogin(c: TForumData, username, password: string): string =
725725
## Performs a login with the specified details.
726726
##

0 commit comments

Comments
 (0)