Spammers are now hidden from the thread list properly.
This commit is contained in:
parent
c566b05347
commit
7baae0bde0
3 changed files with 18 additions and 11 deletions
|
|
@ -248,10 +248,6 @@ $threads-meta-color: #545d70;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#threads-list tr.banned {
|
|
||||||
display: none; // TODO: Fix server so that it doesn't send banned threads.
|
|
||||||
}
|
|
||||||
|
|
||||||
.posts, .about {
|
.posts, .about {
|
||||||
@extend .grid-md;
|
@extend .grid-md;
|
||||||
@extend .container;
|
@extend .container;
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@ proc selectThreadAuthor(threadId: int): User =
|
||||||
|
|
||||||
return selectUser(getRow(db, authorQuery, threadId))
|
return selectUser(getRow(db, authorQuery, threadId))
|
||||||
|
|
||||||
proc selectThread(threadRow: seq[string]): Thread =
|
proc selectThread(threadRow: seq[string], author: User): Thread =
|
||||||
const postsQuery =
|
const postsQuery =
|
||||||
sql"""select count(*), min(strftime('%s', creation)) from post
|
sql"""select count(*), min(strftime('%s', creation)) from post
|
||||||
where thread = ?;"""
|
where thread = ?;"""
|
||||||
|
|
@ -418,7 +418,7 @@ proc selectThread(threadRow: seq[string]): Thread =
|
||||||
thread.users.add(selectUser(user))
|
thread.users.add(selectUser(user))
|
||||||
|
|
||||||
# Grab the author.
|
# Grab the author.
|
||||||
thread.author = selectThreadAuthor(thread.id)
|
thread.author = author
|
||||||
|
|
||||||
return thread
|
return thread
|
||||||
|
|
||||||
|
|
@ -762,9 +762,19 @@ routes:
|
||||||
|
|
||||||
const threadsQuery =
|
const threadsQuery =
|
||||||
sql"""select t.id, t.name, views, strftime('%s', modified), isLocked,
|
sql"""select t.id, t.name, views, strftime('%s', modified), isLocked,
|
||||||
c.id, c.name, c.description, c.color
|
c.id, c.name, c.description, c.color,
|
||||||
from thread t, category c
|
u.name, u.email, strftime('%s', u.lastOnline),
|
||||||
where isDeleted = 0 and category = c.id
|
strftime('%s', u.previousVisitAt), u.status, u.isDeleted
|
||||||
|
from thread t, category c, person u
|
||||||
|
where t.isDeleted = 0 and category = c.id and
|
||||||
|
u.status <> 'Spammer' and u.status <> 'Troll' and
|
||||||
|
u.status <> 'Banned' and
|
||||||
|
u.id in (
|
||||||
|
select u.id from post p, person u
|
||||||
|
where p.author = u.id and p.thread = t.id
|
||||||
|
order by u.id
|
||||||
|
limit 1
|
||||||
|
)
|
||||||
order by modified desc limit ?, ?;"""
|
order by modified desc limit ?, ?;"""
|
||||||
|
|
||||||
let thrCount = getValue(db, sql"select count(*) from thread;").parseInt()
|
let thrCount = getValue(db, sql"select count(*) from thread;").parseInt()
|
||||||
|
|
@ -772,7 +782,7 @@ routes:
|
||||||
|
|
||||||
var list = ThreadList(threads: @[], moreCount: moreCount)
|
var list = ThreadList(threads: @[], moreCount: moreCount)
|
||||||
for data in getAllRows(db, threadsQuery, start, count):
|
for data in getAllRows(db, threadsQuery, start, count):
|
||||||
let thread = selectThread(data)
|
let thread = selectThread(data[0 .. 8], selectUser(data[9 .. ^1]))
|
||||||
list.threads.add(thread)
|
list.threads.add(thread)
|
||||||
|
|
||||||
resp $(%list), "application/json"
|
resp $(%list), "application/json"
|
||||||
|
|
@ -793,7 +803,7 @@ routes:
|
||||||
where t.id = ? and isDeleted = 0 and category = c.id;"""
|
where t.id = ? and isDeleted = 0 and category = c.id;"""
|
||||||
|
|
||||||
let threadRow = getRow(db, threadsQuery, id)
|
let threadRow = getRow(db, threadsQuery, id)
|
||||||
let thread = selectThread(threadRow)
|
let thread = selectThread(threadRow, selectThreadAuthor(id))
|
||||||
|
|
||||||
let postsQuery =
|
let postsQuery =
|
||||||
sql(
|
sql(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import times
|
import times
|
||||||
|
|
||||||
type
|
type
|
||||||
|
# If you add more "Banned" states, be sure to modify forum's threadsQuery too.
|
||||||
Rank* {.pure.} = enum ## serialized as 'status'
|
Rank* {.pure.} = enum ## serialized as 'status'
|
||||||
Spammer ## spammer: every post is invisible
|
Spammer ## spammer: every post is invisible
|
||||||
Troll ## troll: cannot write new posts
|
Troll ## troll: cannot write new posts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue