GDPR erasure: user profile and Q&A
parent
c250d595c9
commit
0b439bd578
|
@ -316,7 +316,7 @@ i18n {
|
|||
}
|
||||
detectlanguage.api {
|
||||
url = "http://ws.detectlanguage.com/0.2/detect"
|
||||
key = "???"
|
||||
key = ""
|
||||
}
|
||||
mailgun {
|
||||
api {
|
||||
|
|
|
@ -19,7 +19,8 @@ final class DetectLanguage(url: String, key: String) {
|
|||
private val messageMaxLength = 2000
|
||||
|
||||
def apply(message: String): Fu[Option[Lang]] =
|
||||
WS.url(url).post(Map(
|
||||
if (key.isEmpty) fuccess(Lang("en").some)
|
||||
else WS.url(url).post(Map(
|
||||
"key" -> Seq(key),
|
||||
"q" -> Seq(message take messageMaxLength)
|
||||
)) map { response =>
|
||||
|
|
|
@ -2,6 +2,7 @@ package lila.qa
|
|||
|
||||
import com.typesafe.config.Config
|
||||
import lila.common.DetectLanguage
|
||||
import akka.actor._
|
||||
|
||||
final class Env(
|
||||
config: Config,
|
||||
|
@ -10,6 +11,7 @@ final class Env(
|
|||
mongoCache: lila.memo.MongoCache.Builder,
|
||||
asyncCache: lila.memo.AsyncCache.Builder,
|
||||
notifyApi: lila.notify.NotifyApi,
|
||||
system: akka.actor.ActorSystem,
|
||||
db: lila.db.Env
|
||||
) {
|
||||
|
||||
|
@ -34,6 +36,15 @@ final class Env(
|
|||
lazy val search = new Search(questionColl)
|
||||
|
||||
lazy val forms = new DataForm(hub.actor.captcher, detectLanguage)
|
||||
|
||||
system.lilaBus.subscribe(system.actorOf(Props(new Actor {
|
||||
def receive = {
|
||||
case lila.user.User.GDPRErase(user) => for {
|
||||
_ <- api.question erase user
|
||||
_ <- api.answer erase user
|
||||
} yield ()
|
||||
}
|
||||
})), 'gdprErase)
|
||||
}
|
||||
|
||||
object Env {
|
||||
|
@ -45,6 +56,7 @@ object Env {
|
|||
mongoCache = lila.memo.Env.current.mongoCache,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
notifyApi = lila.notify.Env.current.api,
|
||||
system = lila.common.PlayApp.system,
|
||||
db = lila.db.Env.current
|
||||
)
|
||||
}
|
||||
|
|
|
@ -148,6 +148,13 @@ final class QaApi(
|
|||
case None => $unset("locked")
|
||||
case Some(u) => $set("locked" -> Locked(by = u.id, at = DateTime.now))
|
||||
}).void
|
||||
|
||||
def erase(user: User) = questionColl.distinct[QuestionId, List]("_id", $doc("userId" -> user.id).some).flatMap { ids =>
|
||||
(ids.nonEmpty) ?? {
|
||||
questionColl.remove($inIds(ids)) >>
|
||||
answerColl.remove($doc("questionId" $in ids)).void
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object answer {
|
||||
|
@ -263,6 +270,8 @@ final class QaApi(
|
|||
|
||||
def countByQuestionId(id: QuestionId) =
|
||||
answerColl.count(Some($doc("questionId" -> id)))
|
||||
|
||||
def erase(user: User) = answerColl.remove($doc("userId" -> user.id))
|
||||
}
|
||||
|
||||
object comment {
|
||||
|
|
|
@ -56,6 +56,7 @@ final class Env(
|
|||
case User.Active(user) =>
|
||||
if (!user.seenRecently) UserRepo setSeenAt user.id
|
||||
onlineUserIdMemo put user.id
|
||||
case User.GDPRErase(user) => UserRepo erase user
|
||||
}
|
||||
})), 'adjustCheater, 'adjustBooster, 'userActive, 'kickFromRankings)
|
||||
|
||||
|
|
|
@ -411,6 +411,8 @@ object UserRepo {
|
|||
|
||||
def setEmailConfirmed(id: User.ID): Funit = coll.update($id(id), $unset(F.mustConfirmEmail)).void
|
||||
|
||||
def erase(user: User): Funit = coll.update($id(user.id), $unset(F.profile)).void
|
||||
|
||||
private def newUser(
|
||||
username: String,
|
||||
passwordHash: HashedPassword,
|
||||
|
|
Loading…
Reference in New Issue