verified users can send more messages (for lichess4545)
parent
ad5371a478
commit
15cfe4f508
|
@ -24,14 +24,14 @@ final private class MsgSecurity(
|
|||
import MsgSecurity._
|
||||
|
||||
private val CreateLimitPerUser = new RateLimit[User.ID](
|
||||
credits = 20,
|
||||
credits = 20 * 5,
|
||||
duration = 24 hour,
|
||||
name = "PM creates per user",
|
||||
key = "msg_create.user"
|
||||
)
|
||||
|
||||
private val ReplyLimitPerUser = new RateLimit[User.ID](
|
||||
credits = 20,
|
||||
credits = 20 * 5,
|
||||
duration = 1 minute,
|
||||
name = "PM replies per user",
|
||||
key = "msg_reply.user"
|
||||
|
@ -69,7 +69,8 @@ final private class MsgSecurity(
|
|||
if (unlimited) fuccess(none)
|
||||
else {
|
||||
val limiter = if (isNew) CreateLimitPerUser else ReplyLimitPerUser
|
||||
!limiter(user.id)(true) ?? fuccess(Limit.some)
|
||||
val cost = if (user.isVerified) 1 else 5
|
||||
!limiter(user.id, cost = cost)(true) ?? fuccess(Limit.some)
|
||||
}
|
||||
|
||||
private def isSpam(text: String): Fu[Option[Verdict]] =
|
||||
|
|
|
@ -176,10 +176,11 @@ object User {
|
|||
def isTroll = marks.exists(_.troll)
|
||||
}
|
||||
|
||||
case class Contact(_id: ID, kid: Option[Boolean], marks: Option[UserMarks]) {
|
||||
def id = _id
|
||||
def isKid = ~kid
|
||||
def isTroll = marks.exists(_.troll)
|
||||
case class Contact(_id: ID, kid: Option[Boolean], marks: Option[UserMarks], roles: Option[List[String]]) {
|
||||
def id = _id
|
||||
def isKid = ~kid
|
||||
def isTroll = marks.exists(_.troll)
|
||||
def isVerified = roles.exists(_ contains "ROLE_VERIFIED")
|
||||
}
|
||||
case class Contacts(orig: Contact, dest: Contact)
|
||||
|
||||
|
|
|
@ -580,7 +580,7 @@ final class UserRepo(val coll: Coll)(implicit ec: scala.concurrent.ExecutionCont
|
|||
import User.contactHandler
|
||||
coll.byOrderedIds[User.Contact, User.ID](
|
||||
List(orig, dest),
|
||||
$doc(F.kid -> true, F.marks -> true).some,
|
||||
$doc(F.kid -> true, F.marks -> true, F.roles -> true).some,
|
||||
ReadPreference.secondaryPreferred
|
||||
)(_._id) map {
|
||||
case List(o, d) => User.Contacts(o, d).some
|
||||
|
|
Loading…
Reference in New Issue