Skip to content

Commit

Permalink
stop sending all mod notes to zulip
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jun 28, 2023
1 parent 946abd7 commit 9c22c7b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 32 deletions.
1 change: 0 additions & 1 deletion modules/hub/src/main/actorApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ package fishnet:
package user:

import lila.common.EmailAddress
case class Note(from: UserName, to: UserName, text: String, mod: Boolean)
case class ChangeEmail(id: UserId, email: EmailAddress)

package round:
Expand Down
8 changes: 3 additions & 5 deletions modules/irc/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import lila.common.Lilakka
import lila.common.config.*
import lila.hub.actorApi.plan.ChargeEvent
import lila.hub.actorApi.irc.Event
import lila.hub.actorApi.user.Note

@Module
final class Env(
Expand All @@ -30,8 +29,7 @@ final class Env(
api.publishInfo("Lichess has started!")
Lilakka.shutdown(shutdown, _.PhaseBeforeServiceUnbind, "Tell IRC")((() => api.stop()))

lila.common.Bus.subscribeFun("slack", "plan", "userNote") {
case d: ChargeEvent => api.charge(d).unit
case Note(from, to, text, true) if from.value != "Irwin" => api.userModNote(from, to, text).unit
case e: Event => api.publishEvent(e).unit
lila.common.Bus.subscribeFun("slack", "plan") {
case d: ChargeEvent => api.charge(d).unit
case e: Event => api.publishEvent(e).unit
}
6 changes: 0 additions & 6 deletions modules/irc/src/main/IrcApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ final class IrcApi(
zulip(_.mod.cafeteria, "reports"):
s"**${markdown.userLinkNoNotes(user.username)}** usertable check (requested by ${markdown.modLink(mod.username)})"

def userModNote(modName: UserName, username: UserName, note: String): Funit =
(!User.isLichess(modName)).so:
zulip(_.mod.adminLog, "notes"):
s"${markdown.modLink(modName)} :note: **${markdown.userLink(username)}** (${markdown.userNotesLink(username)}):\n" +
markdown.linkifyUsers(note take 2000)

def selfReport(typ: String, path: String, user: User, ip: IpAddress): Funit =
zulip(_.mod.adminLog, "self report"):
s"[**$typ**] ${markdown.userLink(user)}@$ip ${markdown.gameLink(path)}"
Expand Down
29 changes: 9 additions & 20 deletions modules/user/src/main/NoteApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,15 @@ final class NoteApi(
.list(100)

def write(to: User, text: String, modOnly: Boolean, dox: Boolean)(using me: Me) = {

val note = Note(
_id = ThreadLocalRandom nextString 8,
from = me,
to = to.id,
text = text,
mod = modOnly,
dox = modOnly && (dox || Title.fromUrl.toFideId(text).isDefined),
date = nowInstant
)

coll.insert.one(note) >>-
lila.common.Bus.publish(
lila.hub.actorApi.user.Note(
from = me.username,
to = to.username,
text = note.text,
mod = modOnly
),
"userNote"
coll.insert.one:
Note(
_id = ThreadLocalRandom nextString 8,
from = me,
to = to.id,
text = text,
mod = modOnly,
dox = modOnly && (dox || Title.fromUrl.toFideId(text).isDefined),
date = nowInstant
)
} >> {
modOnly so Title.fromUrl(text) flatMap {
Expand Down

0 comments on commit 9c22c7b

Please sign in to comment.