better handle erased forum posts
parent
33dd9551f8
commit
b2046852ea
|
@ -80,7 +80,7 @@ final class ForumPost(env: Env) extends LilaController(env) with ForumController
|
|||
Auth { implicit ctx => me =>
|
||||
postApi getPost id flatMap {
|
||||
_ ?? { post =>
|
||||
if (me.id == ~post.userId)
|
||||
if (me.id == ~post.userId && !post.erased)
|
||||
postApi.erasePost(post) inject Redirect(routes.ForumPost.redirect(id))
|
||||
else
|
||||
isGrantedMod(categSlug) flatMap { granted =>
|
||||
|
|
|
@ -41,7 +41,7 @@ object TeamInfo {
|
|||
|
||||
final class TeamInfoApi(
|
||||
api: TeamApi,
|
||||
forumRecent: lila.forum.Recent,
|
||||
forumRecent: lila.forum.ForumRecent,
|
||||
tourApi: TournamentApi,
|
||||
swissApi: SwissApi,
|
||||
simulApi: SimulApi,
|
||||
|
|
|
@ -41,7 +41,7 @@ object post {
|
|||
)(implicit ctx: Context) = {
|
||||
st.article(cls := List("forum-post" -> true, "erased" -> post.erased), id := post.number)(
|
||||
div(cls := "forum-post__metas")(
|
||||
!post.erased option div(
|
||||
(!post.erased || canModCateg) option div(
|
||||
authorLink(post = post, cssClass = "author".some, modIcon = post.displayModIcon),
|
||||
a(href := url)(
|
||||
post.updatedAt
|
||||
|
@ -55,9 +55,9 @@ object post {
|
|||
momentFromNow(post.createdAt)
|
||||
}
|
||||
),
|
||||
ctx.userId.exists(post.shouldShowEditForm) option
|
||||
(!post.erased && ctx.userId.exists(post.shouldShowEditForm)) option
|
||||
a(cls := "mod edit button button-empty text", dataIcon := "m")("Edit"),
|
||||
if (ctx.userId.has(~post.userId))
|
||||
if (!post.erased && ctx.userId.has(~post.userId))
|
||||
postForm(action := routes.ForumPost.delete(categ.slug, post.id))(
|
||||
submitButton(
|
||||
cls := "mod delete button button-empty confirm",
|
||||
|
|
|
@ -62,7 +62,7 @@ final class Env(
|
|||
|
||||
lazy val mentionNotifier: MentionNotifier = wire[MentionNotifier]
|
||||
lazy val forms = wire[ForumForm]
|
||||
lazy val recent = wire[Recent]
|
||||
lazy val recent = wire[ForumRecent]
|
||||
|
||||
lila.common.Bus.subscribeFun("team", "gdprErase") {
|
||||
case CreateTeam(id, name, _) => categApi.makeTeam(id, name).unit
|
||||
|
|
|
@ -5,7 +5,7 @@ import scala.concurrent.duration._
|
|||
import lila.memo.CacheApi._
|
||||
import lila.user.User
|
||||
|
||||
final class Recent(
|
||||
final class ForumRecent(
|
||||
postApi: PostApi,
|
||||
postRepo: PostRepo,
|
||||
cacheApi: lila.memo.CacheApi,
|
|
@ -50,16 +50,14 @@ final class PostRepo(val coll: Coll, filter: Filter = Safe)(implicit
|
|||
|
||||
def recentInCategs(nb: Int)(categIds: List[String], langs: List[String]): Fu[List[Post]] =
|
||||
coll
|
||||
.find(
|
||||
selectCategs(categIds) ++ selectLangs(langs) ++ selectNotHidden
|
||||
)
|
||||
.find(selectCategs(categIds) ++ selectLangs(langs) ++ selectNotHidden ++ selectNotErased)
|
||||
.sort($sort.createdDesc)
|
||||
.cursor[Post]()
|
||||
.list(nb)
|
||||
|
||||
def recentInCateg(categId: String, nb: Int): Fu[List[Post]] =
|
||||
coll
|
||||
.find(selectCateg(categId) ++ selectNotHidden)
|
||||
.find(selectCateg(categId) ++ selectNotHidden ++ selectNotErased)
|
||||
.sort($sort.createdDesc)
|
||||
.cursor[Post]()
|
||||
.list(nb)
|
||||
|
@ -85,6 +83,7 @@ final class PostRepo(val coll: Coll, filter: Filter = Safe)(implicit
|
|||
def selectCategs(categIds: List[String]) = $doc("categId" $in categIds) ++ trollFilter
|
||||
|
||||
val selectNotHidden = $doc("hidden" -> false)
|
||||
val selectNotErased = $doc("erasedAt" $exists false)
|
||||
|
||||
def selectLangs(langs: List[String]) =
|
||||
if (langs.isEmpty) $empty
|
||||
|
|
Loading…
Reference in New Issue