better monitor PMs sent
parent
77dbf8a845
commit
822054e36b
|
@ -178,8 +178,14 @@ final class Clas(
|
|||
Reasonable(clas, students, "notify") {
|
||||
val url = routes.Clas.show(clas.id.value).url
|
||||
val full = if (text contains url) text else s"$text\n\n${env.net.baseUrl}$url"
|
||||
env.msg.api.multiPost(me, Source(students.map(_.user.id)), full) inject
|
||||
Redirect(routes.Clas.show(clas.id.value)).flashSuccess
|
||||
env.msg.api
|
||||
.multiPost(me, Source(students.map(_.user.id)), full)
|
||||
.addEffect { nb =>
|
||||
lila.mon.msg.clasBulk(clas.id.value).record(nb).unit
|
||||
}
|
||||
.inject {
|
||||
Redirect(routes.Clas.show(clas.id.value)).flashSuccess
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -516,7 +516,7 @@ You received this because you are subscribed to messages of the team $url."""
|
|||
env.msg.api
|
||||
.multiPost(me, env.team.memberStream.subscribedIds(team, MaxPerSecond(50)), full)
|
||||
.addEffect { nb =>
|
||||
lila.mon.team.massPm(team.id).record(nb).unit
|
||||
lila.mon.msg.teamBulk(team.id).record(nb).unit
|
||||
}
|
||||
funit // we don't wait for the stream to complete, it would make lichess time out
|
||||
}(funit)
|
||||
|
|
|
@ -420,8 +420,12 @@ object mon {
|
|||
}
|
||||
def reaction(r: String) = counter("forum.reaction").withTag("reaction", r)
|
||||
}
|
||||
object team {
|
||||
def massPm(teamId: String) = histogram("team.mass-pm").withTag("from", teamId)
|
||||
object msg {
|
||||
def post(verdict: String, isNew: Boolean, multi: Boolean) = counter("msg.post").withTags(
|
||||
Map("verdict" -> verdict, "isNew" -> isNew, "multi" -> multi)
|
||||
)
|
||||
def teamBulk(teamId: String) = histogram("msg.bulk.team").withTag("id", teamId)
|
||||
def clasBulk(clasId: String) = histogram("msg.bulk.clas").withTag("id", clasId)
|
||||
}
|
||||
object puzzle {
|
||||
object selector {
|
||||
|
|
|
@ -86,6 +86,7 @@ final class MsgApi(
|
|||
contacts <- userRepo.contacts(orig, dest) orFail s"Missing convo contact user $orig->$dest"
|
||||
isNew <- !colls.thread.exists($id(threadId))
|
||||
verdict <- security.can.post(contacts, msgPre.text, isNew, unlimited = multi)
|
||||
_ = lila.mon.msg.post(verdict.toString, isNew = isNew, multi = multi).increment()
|
||||
res <- verdict match {
|
||||
case MsgSecurity.Limit => fuccess(PostResult.Limited)
|
||||
case _: MsgSecurity.Reject => fuccess(PostResult.Bounced)
|
||||
|
|
Loading…
Reference in New Issue