fix appeal locking - closes #9367
parent
a367780a0a
commit
f5e4d21e91
|
@ -311,12 +311,20 @@ final class Mod(
|
|||
Secure(_.SeeReport) { implicit ctx => me =>
|
||||
OptionFuResult(env.user.repo named username) { user =>
|
||||
(isGranted(_.Appeals) ?? env.appeal.api.exists(user)) flatMap { isAppeal =>
|
||||
val f =
|
||||
if (isAppeal) env.report.api.inquiries.appeal _
|
||||
else env.report.api.inquiries.spontaneous _
|
||||
f(me, Suspect(user)) inject {
|
||||
if (isAppeal) Redirect(s"${routes.Appeal.show(user.username)}#appeal-actions")
|
||||
else redirect(user.username, mod = true)
|
||||
isAppeal.??(env.report.api.inquiries.ongoingAppealOf(user.id)) flatMap {
|
||||
case Some(ongoing) if ongoing.mod != me.id =>
|
||||
env.user.lightUserApi.asyncFallback(ongoing.mod) map { mod =>
|
||||
Redirect(routes.Appeal.show(user.username))
|
||||
.flashFailure(s"Currently processed by ${mod.name}")
|
||||
}
|
||||
case _ =>
|
||||
val f =
|
||||
if (isAppeal) env.report.api.inquiries.appeal _
|
||||
else env.report.api.inquiries.spontaneous _
|
||||
f(me, Suspect(user)) inject {
|
||||
if (isAppeal) Redirect(s"${routes.Appeal.show(user.username)}#appeal-actions")
|
||||
else redirect(user.username, mod = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -556,6 +556,17 @@ final class ReportApi(
|
|||
def ofSuspectId(suspectId: User.ID): Fu[Option[Report.Inquiry]] =
|
||||
coll.primitiveOne[Report.Inquiry]($doc("inquiry.mod" $exists true, "user" -> suspectId), "inquiry")
|
||||
|
||||
def ongoingAppealOf(suspectId: User.ID): Fu[Option[Report.Inquiry]] =
|
||||
coll.primitiveOne[Report.Inquiry](
|
||||
$doc(
|
||||
"inquiry.mod" $exists true,
|
||||
"user" -> suspectId,
|
||||
"room" -> Room.Other.key,
|
||||
"atoms.0.text" -> Report.appealText
|
||||
),
|
||||
"inquiry"
|
||||
)
|
||||
|
||||
/*
|
||||
* If the mod has no current inquiry, just start this one.
|
||||
* If they had another inquiry, cancel it and start this one instead.
|
||||
|
|
Loading…
Reference in New Issue