Log anon mod post and anon mod post edit

Since nothing is tied to the real author in the db.
pull/9478/head
kraktus 2021-07-27 16:52:01 +02:00
parent 8058f484bf
commit 2c8509ab0a
3 changed files with 43 additions and 3 deletions

View File

@ -65,6 +65,15 @@ final class PostApi(
if (post.isTeam) lila.hub.actorApi.shutup.RecordTeamForumMessage(me.id, post.text)
else lila.hub.actorApi.shutup.RecordPublicForumMessage(me.id, post.text)
}
if (anonMod)
modLog.postOrEditAsAnonMod(
me.id,
post.categId,
post.topicId,
post.id,
post.text,
edit = false
)
if (!post.troll && !categ.quiet && !topic.isTooBig && !anonMod)
timeline ! Propagate(ForumPost(me.id, topic.id.some, topic.name, post.id)).pipe {
_ toFollowersOf me.id toUsers topicUserIds exceptUser me.id
@ -86,7 +95,16 @@ final class PostApi(
case (_, post) =>
val newPost = post.editPost(DateTime.now, spam replace newText)
(newPost.text != post.text).?? {
env.postRepo.coll.update.one($id(post.id), newPost).void
env.postRepo.coll.update.one($id(post.id), newPost) >> newPost.isAnonModPost.?? {
modLog.postOrEditAsAnonMod(
user.id,
newPost.categId,
newPost.topicId,
newPost.id,
newPost.text,
edit = true
)
}
} inject newPost
}
}

View File

@ -38,6 +38,8 @@ case class Modlog(
case Modlog.hideTopic => "unfeature topic"
case Modlog.stickyTopic => "sticky topic"
case Modlog.unstickyTopic => "un-sticky topic"
case Modlog.postAsAnonMod => "post as a lichess moderator"
case Modlog.editAsAnonMod => "edit a lichess moderator post"
case Modlog.setTitle => "set FIDE title"
case Modlog.removeTitle => "remove FIDE title"
case Modlog.setEmail => "set email address"
@ -106,6 +108,8 @@ object Modlog {
val hideTopic = "hideTopic"
val stickyTopic = "stickyTopic"
val unstickyTopic = "unstickyTopic"
val postAsAnonMod = "postAsAnonMod"
val editAsAnonMod = "editAsAnonMod"
val setTitle = "setTitle"
val removeTitle = "removeTitle"
val setEmail = "setEmail"

View File

@ -150,6 +150,24 @@ final class ModlogApi(repo: ModlogRepo, userRepo: UserRepo, ircApi: IrcApi)(impl
)
}
// Not to be confused with the eponymous lichess account.
def postOrEditAsAnonMod(
mod: User.ID,
categ: String,
topic: String,
postId: String,
text: String,
edit: Boolean
) =
add {
Modlog(
mod,
none,
if (edit) Modlog.editAsAnonMod else Modlog.postAsAnonMod,
details = s"$categ/$topic id: $postId ${text.take(400)}".some
)
}
def deleteTeam(mod: User.ID, id: String, name: String) =
add {
Modlog(mod, none, Modlog.deleteTeam, details = s"$id / $name".take(200).some)
@ -283,7 +301,7 @@ final class ModlogApi(repo: ModlogRepo, userRepo: UserRepo, ircApi: IrcApi)(impl
case M.chatTimeout => "hourglass_flowing_sand"
case M.closeTopic | M.disableTeam => "lock"
case M.openTopic | M.enableTeam => "unlock"
case M.modMessage => "left_speech_bubble"
case M.modMessage | M.postAsAnonMod | M.editAsAnonMod => "left_speech_bubble"
case _ => "gear"
}
val text = s"""${m.showAction.capitalize} ${m.user.??(u => s"@$u")} ${~m.details}"""
@ -294,7 +312,7 @@ final class ModlogApi(repo: ModlogRepo, userRepo: UserRepo, ircApi: IrcApi)(impl
case M.engine | M.unengine | M.booster | M.unbooster | M.reopenAccount | M.unalt =>
Some(IrcApi.ModDomain.Hunt)
case M.troll | M.untroll | M.chatTimeout | M.closeTopic | M.openTopic | M.disableTeam |
M.enableTeam | M.setKidMode | M.deletePost =>
M.enableTeam | M.setKidMode | M.deletePost | M.postAsAnonMod | M.editAsAnonMod =>
Some(IrcApi.ModDomain.Comm)
case _ => Some(IrcApi.ModDomain.Other)
}