msg chat panic support
parent
20df9d8a48
commit
a5e3d098c3
|
@ -354,7 +354,7 @@ lazy val message = module("message",
|
|||
)
|
||||
|
||||
lazy val msg = module("msg",
|
||||
Seq(common, db, user, hub, relation, security, shutup, notifyModule),
|
||||
Seq(common, db, user, hub, relation, security, shutup, notifyModule, chat),
|
||||
reactivemongo.bundle
|
||||
)
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ final class ChatPanic {
|
|||
}
|
||||
def allowed(u: User): Boolean = allowed(u, false)
|
||||
|
||||
def allowed(id: User.ID, fetch: User.ID => Fu[Option[User]]): Fu[Boolean] =
|
||||
if (enabled) fetch(id) dmap { _ ?? allowed } else fuTrue
|
||||
|
||||
def enabled = until exists { d =>
|
||||
(d isAfter DateTime.now) || {
|
||||
until = none
|
||||
|
|
|
@ -17,7 +17,8 @@ final class Env(
|
|||
prefApi: lila.pref.PrefApi,
|
||||
notifyApi: lila.notify.NotifyApi,
|
||||
cacheApi: lila.memo.CacheApi,
|
||||
spam: lila.security.Spam
|
||||
spam: lila.security.Spam,
|
||||
chatPanic: lila.chat.ChatPanic
|
||||
)(implicit ec: scala.concurrent.ExecutionContext, scheduler: akka.actor.Scheduler) {
|
||||
|
||||
private val colls = wire[MsgColls]
|
||||
|
|
|
@ -15,7 +15,8 @@ final private class MsgSecurity(
|
|||
prefApi: lila.pref.PrefApi,
|
||||
userRepo: lila.user.UserRepo,
|
||||
relationApi: lila.relation.RelationApi,
|
||||
spam: lila.security.Spam
|
||||
spam: lila.security.Spam,
|
||||
chatPanic: lila.chat.ChatPanic
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
import BsonHandlers._
|
||||
|
@ -81,7 +82,7 @@ final private class MsgSecurity(
|
|||
def post(orig: User.ID, dest: User.ID): Fu[Boolean] = (dest != User.lichessId) ?? {
|
||||
!relationApi.fetchBlocks(dest, orig) >>& {
|
||||
create(orig, dest) >>| reply(orig, dest)
|
||||
}
|
||||
} >>& chatPanic.allowed(orig, userRepo.byId)
|
||||
}
|
||||
|
||||
private def create(orig: User.ID, dest: User.ID): Fu[Boolean] =
|
||||
|
|
Loading…
Reference in New Issue