posts from spammers are not visible

This commit is contained in:
Andreas Rumpf 2017-01-02 10:55:54 +01:00
commit a2edc92fc5
2 changed files with 17 additions and 9 deletions

View file

@ -7,11 +7,12 @@
#
#proc genThreadsList(c: var TForumData, count: var int): string =
# const queryAdmin = sql"""select id, name, views, modified from thread
# where 1 or id = ?
# where id in (select thread from post where author in
# (select id from person where status not in ('Spammer') or id = ?))
# order by modified desc limit ?, ?"""
# const query = sql"""select id, name, views, modified from thread
# where id in (select thread from post where author in
# (select id from person where status <> 'Moderated' or id = ?))
# (select id from person where status not in ('Moderated', 'Spammer') or id = ?))
# order by modified desc limit ?, ?"""
# const threadId = 0
# const name = 1
@ -122,6 +123,7 @@
# let query = sql("""select p.id, u.name, p.header, p.content, p.creation, p.author, u.email from post p,
# person u
# where u.id = p.author and p.thread = ? and $#
# and (u.status <> 'Spammer' or p.author = ?)
# order by p.id limit ?, ?""" %
# (if c.rank >= Moderator: "(1 or u.id = ?)" else: "(u.status <> 'Moderated' or p.author = ?)"))
# const postId = 0
@ -133,7 +135,7 @@
# const userEmail = 6
# result = ""
# count = 0
# let posts = getAllRows(db, query, threadId, c.userId, $((c.pageNum-1) * PostsPerPage), $PostsPerPage)
# let posts = getAllRows(db, query, threadId, c.userId, c.userId, $((c.pageNum-1) * PostsPerPage), $PostsPerPage)
# if posts.len < 1: return ""
# end if
<div id="talk-head">

View file

@ -704,18 +704,24 @@ proc verifyIdentHash(c: var TForumData, name, epoch, ident: string): bool =
if row[2].parseInt > (epoch.parseInt + 60): return false
result = newIdent == ident
proc setStatus(c: var TForumData, nick: string, status: Rank;
reason: string): bool =
const query =
sql("update person set status = ?, ban = ? where name = ?")
return tryExec(db, query, $status, reason, nick)
proc deleteAll(c: var TForumData, nick: string): bool =
const query =
sql("delete from post where author = (select id from person where name = ?)")
result = tryExec(db, query, nick)
result = result and updateThreads(c) >= 0
proc setStatus(c: var TForumData, nick: string, status: Rank;
reason: string): bool =
const query =
sql("update person set status = ?, ban = ? where name = ?")
result = tryExec(db, query, $status, reason, nick)
when false:
# for now we filter Spammers in forms.tmpl, so that a moderator
# cannot accidentically delete all of a user's posts. We go even
# further than that and show spammers their own spam postings.
if status == Spammer and result:
result = deleteAll(c, nick)
proc setPassword(c: var TForumData, nick, pass: string): bool =
const query =
sql("update person set password = ?, salt = ? where name = ?")