remove blocking forum granter
This commit is contained in:
parent
3ba1a5b55f
commit
c23cc60a24
|
@ -1,8 +1,8 @@
|
||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import scala.concurrent.duration._
|
|
||||||
import lila.common.HTTPRequest
|
|
||||||
import lila.app._
|
import lila.app._
|
||||||
|
import lila.common.HTTPRequest
|
||||||
|
import scala.concurrent.duration._
|
||||||
import views._
|
import views._
|
||||||
|
|
||||||
object ForumPost extends LilaController with ForumController {
|
object ForumPost extends LilaController with ForumController {
|
||||||
|
@ -38,11 +38,11 @@ object ForumPost extends LilaController with ForumController {
|
||||||
case (categ, topic, posts) =>
|
case (categ, topic, posts) =>
|
||||||
if (topic.closed) fuccess(BadRequest("This topic is closed"))
|
if (topic.closed) fuccess(BadRequest("This topic is closed"))
|
||||||
else forms.post.bindFromRequest.fold(
|
else forms.post.bindFromRequest.fold(
|
||||||
err => forms.anyCaptcha flatMap { captcha =>
|
err => for {
|
||||||
ctx.userId ?? Env.timeline.status(s"forum:${topic.id}") map { unsub =>
|
captcha <- forms.anyCaptcha
|
||||||
BadRequest(html.forum.topic.show(categ, topic, posts, Some(err -> captcha), unsub))
|
unsub <- ctx.userId ?? Env.timeline.status(s"forum:${topic.id}")
|
||||||
}
|
canModCateg <- isGrantedMod(categ.slug)
|
||||||
},
|
} yield BadRequest(html.forum.topic.show(categ, topic, posts, Some(err -> captcha), unsub, canModCateg = canModCateg)),
|
||||||
data => postApi.makePost(categ, topic, data) map { post =>
|
data => postApi.makePost(categ, topic, data) map { post =>
|
||||||
Redirect(routes.ForumPost.redirect(post.id))
|
Redirect(routes.ForumPost.redirect(post.id))
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,11 @@ object ForumPost extends LilaController with ForumController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def edit(postId: String) = AuthBody { implicit ctx =>
|
def edit(postId: String) = AuthBody { implicit ctx => me =>
|
||||||
me =>
|
|
||||||
implicit val req = ctx.body
|
implicit val req = ctx.body
|
||||||
|
|
||||||
forms.postEdit.bindFromRequest.fold(err => Redirect(routes.ForumPost.redirect(postId)).fuccess,
|
forms.postEdit.bindFromRequest.fold(
|
||||||
|
err => Redirect(routes.ForumPost.redirect(postId)).fuccess,
|
||||||
data =>
|
data =>
|
||||||
postApi.editPost(postId, data.changes, me).map { post =>
|
postApi.editPost(postId, data.changes, me).map { post =>
|
||||||
Redirect(routes.ForumPost.redirect(post.id))
|
Redirect(routes.ForumPost.redirect(post.id))
|
||||||
|
@ -64,8 +64,7 @@ object ForumPost extends LilaController with ForumController {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
def delete(categSlug: String, id: String) = Auth { implicit ctx =>
|
def delete(categSlug: String, id: String) = Auth { implicit ctx => me =>
|
||||||
me =>
|
|
||||||
CategGrantMod(categSlug) {
|
CategGrantMod(categSlug) {
|
||||||
postApi.delete(categSlug, id, me) map { Ok(_) }
|
postApi.delete(categSlug, id, me) map { Ok(_) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package controllers
|
||||||
|
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
import lila.common.HTTPRequest
|
|
||||||
import lila.app._
|
import lila.app._
|
||||||
|
import lila.common.HTTPRequest
|
||||||
import lila.forum.CategRepo
|
import lila.forum.CategRepo
|
||||||
import play.api.libs.json._
|
import play.api.libs.json._
|
||||||
import views._
|
import views._
|
||||||
|
@ -46,19 +46,17 @@ object ForumTopic extends LilaController with ForumController {
|
||||||
NotForKids {
|
NotForKids {
|
||||||
CategGrantRead(categSlug) {
|
CategGrantRead(categSlug) {
|
||||||
OptionFuOk(topicApi.show(categSlug, slug, page, ctx.troll)) {
|
OptionFuOk(topicApi.show(categSlug, slug, page, ctx.troll)) {
|
||||||
case (categ, topic, posts) =>
|
case (categ, topic, posts) => for {
|
||||||
ctx.userId ?? Env.timeline.status(s"forum:${topic.id}") flatMap { unsub =>
|
unsub <- ctx.userId ?? Env.timeline.status(s"forum:${topic.id}")
|
||||||
(!posts.hasNextPage && isGrantedWrite(categSlug) && topic.open) ?? forms.postWithCaptcha.map(_.some) map { form =>
|
form <- (!posts.hasNextPage && isGrantedWrite(categSlug) && topic.open) ?? forms.postWithCaptcha.map(_.some)
|
||||||
html.forum.topic.show(categ, topic, posts, form, unsub)
|
canModCateg <- isGrantedMod(categ.slug)
|
||||||
}
|
} yield html.forum.topic.show(categ, topic, posts, form, unsub, canModCateg = canModCateg)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def close(categSlug: String, slug: String) = Auth { implicit ctx =>
|
def close(categSlug: String, slug: String) = Auth { implicit ctx => me =>
|
||||||
me =>
|
|
||||||
CategGrantMod(categSlug) {
|
CategGrantMod(categSlug) {
|
||||||
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.troll)) {
|
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.troll)) {
|
||||||
case (categ, topic, pag) => topicApi.toggleClose(categ, topic, me) inject
|
case (categ, topic, pag) => topicApi.toggleClose(categ, topic, me) inject
|
||||||
|
@ -67,8 +65,7 @@ object ForumTopic extends LilaController with ForumController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def hide(categSlug: String, slug: String) = Secure(_.ModerateForum) { implicit ctx =>
|
def hide(categSlug: String, slug: String) = Secure(_.ModerateForum) { implicit ctx => me =>
|
||||||
me =>
|
|
||||||
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.troll)) {
|
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.troll)) {
|
||||||
case (categ, topic, pag) => topicApi.toggleHide(categ, topic, me) inject
|
case (categ, topic, pag) => topicApi.toggleHide(categ, topic, me) inject
|
||||||
routes.ForumTopic.show(categSlug, slug, pag.nbPages)
|
routes.ForumTopic.show(categSlug, slug, pag.nbPages)
|
||||||
|
|
|
@ -23,9 +23,6 @@ trait ForumHelper { self: UserHelper with StringHelper =>
|
||||||
def isGrantedWrite(categSlug: String)(implicit ctx: Context) =
|
def isGrantedWrite(categSlug: String)(implicit ctx: Context) =
|
||||||
Granter isGrantedWrite categSlug
|
Granter isGrantedWrite categSlug
|
||||||
|
|
||||||
def isGrantedMod(categSlug: String)(implicit ctx: Context) =
|
|
||||||
Granter.isGrantedMod(categSlug).await
|
|
||||||
|
|
||||||
def authorName(post: Post) = post.userId match {
|
def authorName(post: Post) = post.userId match {
|
||||||
case Some(userId) => userIdSpanMini(userId, withOnline = true)
|
case Some(userId) => userIdSpanMini(userId, withOnline = true)
|
||||||
case None => Html(lila.user.User.anonymous)
|
case None => Html(lila.user.User.anonymous)
|
||||||
|
|
Loading…
Reference in a new issue