fix appeal snooze race condition

pull/9747/head
Thibault Duplessis 2021-09-07 08:15:02 +02:00
parent 1d8605bde5
commit 2a7352fe99
1 changed files with 11 additions and 9 deletions

View File

@ -582,18 +582,20 @@ final class ReportApi(
for {
report <- coll.byId[Report](id) orElse coll.one[Report](
$doc("user" -> id, "inquiry.mod" $exists true)
) orFail s"No report $id found"
)
current <- ofModId(mod.user.id)
_ <- current ?? cancel(mod)
_ <-
report.inquiry.isEmpty ?? coll
.updateField(
$id(report.id),
"inquiry",
Report.Inquiry(mod.user.id, DateTime.now)
)
.void
} yield (current, report.inquiry.isEmpty option report)
report ?? { r =>
r.inquiry.isEmpty ?? coll
.updateField(
$id(r.id),
"inquiry",
Report.Inquiry(mod.user.id, DateTime.now)
)
.void
}
} yield (current, report.filter(_.inquiry.isEmpty))
def toggleNext(mod: Mod, room: Room): Fu[Option[Report]] =
workQueue {