redirect to user page with ?mod after spontaneous mod actions
parent
8ca17bfa8d
commit
4c495f9ad1
|
@ -24,7 +24,7 @@ object Mod extends LilaController {
|
|||
for {
|
||||
inquiry <- Env.report.api.inquiries ofModId me.id
|
||||
_ <- modApi.setEngine(AsMod(me), sus, v)
|
||||
res <- Report.onInquiryClose(inquiry, me)
|
||||
res <- Report.onInquiryClose(inquiry, me, sus.some)
|
||||
} yield res
|
||||
}
|
||||
}
|
||||
|
@ -49,21 +49,21 @@ object Mod extends LilaController {
|
|||
withSuspect(username) { prev =>
|
||||
for {
|
||||
inquiry <- Env.report.api.inquiries ofModId me.id
|
||||
_ <- modApi.setTroll(AsMod(me), prev, v)
|
||||
res <- Report.onInquiryClose(inquiry, me)
|
||||
suspect <- modApi.setTroll(AsMod(me), prev, v)
|
||||
res <- Report.onInquiryClose(inquiry, me, suspect.some)
|
||||
} yield res
|
||||
}
|
||||
}
|
||||
|
||||
def warn(username: String, subject: String) = SecureBody(_.ModMessage) { implicit ctx => me =>
|
||||
lila.message.ModPreset.bySubject(subject).fold(notFound) { preset =>
|
||||
withSuspect(username) { sus =>
|
||||
withSuspect(username) { prev =>
|
||||
for {
|
||||
inquiry <- Env.report.api.inquiries ofModId me.id
|
||||
_ <- modApi.setTroll(AsMod(me), sus, sus.user.troll)
|
||||
thread <- Env.message.api.sendPreset(me, sus.user, preset)
|
||||
suspect <- modApi.setTroll(AsMod(me), prev, prev.user.troll)
|
||||
thread <- Env.message.api.sendPreset(me, suspect.user, preset)
|
||||
_ <- Env.mod.logApi.modMessage(thread.creatorId, thread.invitedId, thread.name)
|
||||
res <- Report.onInquiryClose(inquiry, me)
|
||||
res <- Report.onInquiryClose(inquiry, me, suspect.some)
|
||||
} yield res
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ object Mod extends LilaController {
|
|||
|
||||
def spontaneousInquiry(username: String) = Secure(_.SeeReport) { implicit ctx => me =>
|
||||
OptionFuResult(UserRepo named username) { user =>
|
||||
Env.report.api.inquiries.spontaneous(AsMod(me), Suspect(user)) inject Redirect(routes.User.show(user.username) + "?mod")
|
||||
Env.report.api.inquiries.spontaneous(AsMod(me), Suspect(user)) inject redirect(user.username, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import views._
|
|||
|
||||
import lila.api.{ Context, BodyContext }
|
||||
import lila.app._
|
||||
import lila.report.{ Room, Report => ReportModel, Mod => AsMod }
|
||||
import lila.report.{ Room, Report => ReportModel, Mod => AsMod, Suspect }
|
||||
import lila.user.{ UserRepo, User => UserModel }
|
||||
|
||||
object Report extends LilaController {
|
||||
|
@ -39,18 +39,27 @@ object Report extends LilaController {
|
|||
}
|
||||
|
||||
private def onInquiryStart(inquiry: ReportModel) =
|
||||
Redirect(inquiry.room match {
|
||||
case Room.Coms => routes.Mod.communicationPrivate(inquiry.user).url
|
||||
case _ => routes.User.show(inquiry.user).url + "?mod"
|
||||
})
|
||||
inquiry.room match {
|
||||
case Room.Coms => Redirect(routes.Mod.communicationPrivate(inquiry.user))
|
||||
case _ => Mod.redirect(inquiry.user, true)
|
||||
}
|
||||
|
||||
protected[controllers] def onInquiryClose(inquiry: Option[ReportModel], me: UserModel, force: Boolean = false)(implicit ctx: BodyContext[_]) = {
|
||||
protected[controllers] def onInquiryClose(
|
||||
inquiry: Option[ReportModel],
|
||||
me: UserModel,
|
||||
goTo: Option[Suspect],
|
||||
force: Boolean = false
|
||||
)(implicit ctx: BodyContext[_]) = {
|
||||
def autoNext = ctx.body.body match {
|
||||
case AnyContentAsFormUrlEncoded(data) => data.get("next").exists(_.headOption contains "1")
|
||||
case _ => false
|
||||
}
|
||||
inquiry match {
|
||||
case None => Redirect(routes.Report.list).fuccess
|
||||
case None => {
|
||||
goTo.fold(Redirect(routes.Report.list)) { s =>
|
||||
Mod.redirect(s.user.username, true)
|
||||
}.fuccess
|
||||
}
|
||||
case Some(prev) =>
|
||||
def redirectToList = Redirect(routes.Report.listWithFilter(prev.room.key))
|
||||
if (autoNext) api.next(prev.room) flatMap {
|
||||
|
@ -69,7 +78,7 @@ object Report extends LilaController {
|
|||
|
||||
def process(id: String) = SecureBody(_.SeeReport) { implicit ctx => me =>
|
||||
Env.report.api.inquiries ofModId me.id flatMap { inquiry =>
|
||||
api.process(AsMod(me), id) >> onInquiryClose(inquiry, me, force = true)
|
||||
api.process(AsMod(me), id) >> onInquiryClose(inquiry, me, none, force = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ final class ModApi(
|
|||
case true =>
|
||||
}
|
||||
|
||||
def setTroll(mod: Mod, prev: Suspect, value: Boolean): Funit = {
|
||||
def setTroll(mod: Mod, prev: Suspect, value: Boolean): Fu[Suspect] = {
|
||||
val changed = value != prev.user.troll
|
||||
val sus = prev.set(_.copy(troll = value))
|
||||
changed ?? {
|
||||
|
@ -73,7 +73,7 @@ final class ModApi(
|
|||
} >>
|
||||
reportApi.process(mod, sus, Set(Room.Coms)) >>- {
|
||||
if (value) notifier.reporters(mod, sus)
|
||||
}
|
||||
} inject sus
|
||||
}
|
||||
|
||||
def setBan(mod: Mod, prev: Suspect, value: Boolean): Funit = for {
|
||||
|
|
Loading…
Reference in New Issue