Skip to content

Commit

Permalink
Remove integration with braintracing databases (#7693)
Browse files Browse the repository at this point in the history
* Remove integration with braintracing databases

* changelog + migration guide
  • Loading branch information
fm3 committed Mar 18, 2024
1 parent 9a86c29 commit 29fddc6
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 157 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed an error in the Loki integration to support Loki 2.9+. [#7684](https://github.com/scalableminds/webknossos/pull/7684)

### Removed
- Removed the integration with BrainTracing user databases. [#7693](https://github.com/scalableminds/webknossos/pull/7693)

### Breaking Changes
- Updated antd UI library from version 4.24.15 to 5.13.2. Drop support for nodeJs version <18. [#7522](https://github.com/scalableminds/webknossos/pull/7522)
1 change: 1 addition & 0 deletions MIGRATIONS.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ UPDATE webknossos.annotations_ SET state = 'Finished' WHERE _id IN (SELECT DIST
- NodeJS version 18+ is required for snapshot tests with ShadowDOM elements from Antd v5. [#7522](https://github.com/scalableminds/webknossos/pull/7522)
- Email verification is disabled by default. To enable it, set `webKnossos.user.emailVerification.activated` to `true` in your `application.conf`. [#7620](https://github.com/scalableminds/webknossos/pull/7620) [#7621](https://github.com/scalableminds/webknossos/pull/7621)
- New dependency draco/libdraco-dev needs to be installed when deploying without docker and for local development.
- Config block `braintracing` is now unused and can be removed. [#7693](https://github.com/scalableminds/webknossos/pull/7693)

### Postgres Evolutions:

Expand Down
31 changes: 11 additions & 20 deletions app/controllers/AuthenticationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.apache.commons.codec.digest.{HmacAlgorithms, HmacUtils}
import play.api.data.Form
import play.api.data.Forms.{email, _}
import play.api.data.validation.Constraints._
import play.api.i18n.{Messages, MessagesProvider}
import play.api.i18n.Messages
import play.api.libs.json._
import play.api.mvc.{Action, AnyContent, Cookie, PlayBodyParsers, Request, Result}
import security.{
Expand All @@ -35,7 +35,6 @@ import security.{
WkEnv,
WkSilhouetteEnvironment
}
import thirdparty.BrainTracing
import utils.{ObjectId, WkConf}

import java.net.URLEncoder
Expand All @@ -53,7 +52,6 @@ class AuthenticationController @Inject()(
organizationService: OrganizationService,
inviteService: InviteService,
inviteDAO: InviteDAO,
brainTracing: BrainTracing,
mailchimpClient: MailchimpClient,
organizationDAO: OrganizationDAO,
analyticsService: AnalyticsService,
Expand Down Expand Up @@ -111,8 +109,7 @@ class AuthenticationController @Inject()(
lastName,
autoActivate,
Option(signUpData.password),
inviteBox,
registerBrainDB = true)
inviteBox)
} yield Ok
}
} yield {
Expand All @@ -130,8 +127,7 @@ class AuthenticationController @Inject()(
autoActivate: Boolean,
password: Option[String],
inviteBox: Box[Invite] = Empty,
registerBrainDB: Boolean = false,
isEmailVerified: Boolean = false)(implicit mp: MessagesProvider): Fox[User] = {
isEmailVerified: Boolean = false): Fox[User] = {
val passwordInfo: PasswordInfo = userService.getPasswordInfo(password)
for {
user <- userService.insert(organization._id,
Expand All @@ -147,20 +143,14 @@ class AuthenticationController @Inject()(
_ = analyticsService.track(SignupEvent(user, inviteBox.isDefined))
_ <- Fox.runIf(inviteBox.isDefined)(Fox.runOptional(inviteBox.toOption)(i =>
inviteService.deactivateUsedInvite(i)(GlobalAccessContext)))
brainDBResult <- Fox.runIf(registerBrainDB)(brainTracing.registerIfNeeded(user, password.getOrElse("")))
newUserEmailRecipient <- organizationService.newUserMailRecipient(organization)(GlobalAccessContext)
_ = if (conf.Features.isWkorgInstance) {
mailchimpClient.registerUser(user, multiUser, tag = MailchimpTag.RegisteredAsUser)
} else {
Mailer ! Send(defaultMails.newUserMail(user.name, email, brainDBResult.flatten, autoActivate))
Mailer ! Send(defaultMails.newUserMail(user.name, email, autoActivate))
}
_ = Mailer ! Send(
defaultMails.registerAdminNotifierMail(user.name,
email,
brainDBResult.flatten,
organization,
autoActivate,
newUserEmailRecipient))
defaultMails.registerAdminNotifierMail(user.name, email, organization, autoActivate, newUserEmailRecipient))
} yield {
user
}
Expand Down Expand Up @@ -359,14 +349,16 @@ class AuthenticationController @Inject()(
_ <- Fox.runIf(!requestingMultiUser.isSuperUser)(
organizationService
.assertUsersCanBeAdded(organization._id)(GlobalAccessContext, ec)) ?~> "organization.users.userLimitReached"
_ <- userService.joinOrganization(request.identity, organization._id, autoActivate = invite.autoActivate)
_ <- userService.joinOrganization(request.identity,
organization._id,
autoActivate = invite.autoActivate,
isAdmin = false)
_ = analyticsService.track(JoinOrganizationEvent(request.identity, organization))
userEmail <- userService.emailFor(request.identity)
newUserEmailRecipient <- organizationService.newUserMailRecipient(organization)
_ = Mailer ! Send(
defaultMails.registerAdminNotifierMail(request.identity.name,
userEmail,
None,
organization,
invite.autoActivate,
newUserEmailRecipient))
Expand Down Expand Up @@ -675,8 +667,7 @@ class AuthenticationController @Inject()(
lastName,
request.body.autoActivate.getOrElse(false),
request.body.password,
Empty,
registerBrainDB = true).map(u => Ok(u._id.toString))
Empty).map(u => Ok(u._id.toString))
} else {
Fox.successful(BadRequest(Json.obj("messages" -> Json.toJson(errors.map(t => Json.obj("error" -> t))))))
}
Expand Down Expand Up @@ -734,7 +725,7 @@ object InviteParameters {

trait AuthForms {

val passwordMinLength = 8
private val passwordMinLength = 8

// Sign up
case class SignUpData(organization: String,
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/OrganizationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class OrganizationController @Inject()(
_ = Mailer ! Send(defaultMails.extendPricingPlanMail(request.identity, userEmail))
_ = Mailer ! Send(
defaultMails.upgradePricingPlanRequestMail(request.identity,
userEmail,
organization.displayName,
"Extend WEBKNOSSOS plan by a year"))
} yield Ok
Expand All @@ -223,7 +222,6 @@ class OrganizationController @Inject()(
_ = Mailer ! Send(mail(request.identity, userEmail))
_ = Mailer ! Send(
defaultMails.upgradePricingPlanRequestMail(request.identity,
userEmail,
organization.displayName,
s"Upgrade WEBKNOSSOS Plan to $requestedPlan"))
} yield Ok
Expand All @@ -238,7 +236,6 @@ class OrganizationController @Inject()(
_ = Mailer ! Send(defaultMails.upgradePricingPlanUsersMail(request.identity, userEmail, requestedUsers))
_ = Mailer ! Send(
defaultMails.upgradePricingPlanRequestMail(request.identity,
userEmail,
organization.displayName,
s"Purchase $requestedUsers additional users"))
} yield Ok
Expand All @@ -253,7 +250,6 @@ class OrganizationController @Inject()(
_ = Mailer ! Send(defaultMails.upgradePricingPlanStorageMail(request.identity, userEmail, requestedStorage))
_ = Mailer ! Send(
defaultMails.upgradePricingPlanRequestMail(request.identity,
userEmail,
organization.displayName,
s"Purchase $requestedStorage TB additional storage"))
} yield Ok
Expand Down
26 changes: 6 additions & 20 deletions app/mail/DefaultMails.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package mail

import models.organization.Organization
import models.user.User
import play.api.i18n.{Messages, MessagesProvider}
import utils.WkConf
import views._

Expand All @@ -18,15 +17,14 @@ class DefaultMails @Inject()(conf: WkConf) {

def registerAdminNotifierMail(name: String,
email: String,
brainDBResult: Option[String],
organization: Organization,
autoActivate: Boolean,
recipient: String): Mail =
Mail(
from = defaultSender,
subject =
s"WEBKNOSSOS | A new user ($name, $email) registered on $uri for ${organization.displayName} (${organization.name})",
bodyHtml = html.mail.notifyAdminNewUser(name, brainDBResult, uri, autoActivate).body,
bodyHtml = html.mail.notifyAdminNewUser(name, uri, autoActivate).body,
recipients = List(recipient)
)

Expand All @@ -42,12 +40,11 @@ class DefaultMails @Inject()(conf: WkConf) {
recipients = recipients
)

def newUserMail(name: String, recipient: String, brainDBresult: Option[String], enableAutoVerify: Boolean)(
implicit mp: MessagesProvider): Mail =
def newUserMail(name: String, recipient: String, enableAutoVerify: Boolean): Mail =
Mail(
from = defaultSender,
subject = "Welcome to WEBKNOSSOS",
bodyHtml = html.mail.newUser(name, brainDBresult.map(Messages(_)), enableAutoVerify).body,
bodyHtml = html.mail.newUser(name, enableAutoVerify).body,
recipients = List(recipient)
)

Expand Down Expand Up @@ -121,14 +118,6 @@ class DefaultMails @Inject()(conf: WkConf) {
recipients = List(userEmail)
)

def upgradePricingPlanToPowerMail(user: User, userEmail: String): Mail =
Mail(
from = defaultSender,
subject = "WEBKNOSSOS Plan Upgrade Request",
bodyHtml = html.mail.upgradePricingPlanToPower(user.name).body,
recipients = List(userEmail)
)

def upgradePricingPlanUsersMail(user: User, userEmail: String, requestedUsers: Int): Mail =
Mail(
from = defaultSender,
Expand All @@ -145,10 +134,7 @@ class DefaultMails @Inject()(conf: WkConf) {
recipients = List(userEmail)
)

def upgradePricingPlanRequestMail(user: User,
userEmail: String,
organizationDisplayName: String,
messageBody: String): Mail =
def upgradePricingPlanRequestMail(user: User, organizationDisplayName: String, messageBody: String): Mail =
Mail(
from = defaultSender,
subject = "Request to upgrade WEBKNOSSOS plan",
Expand All @@ -164,7 +150,7 @@ class DefaultMails @Inject()(conf: WkConf) {
jobDescription: String): Mail =
Mail(
from = defaultSender,
subject = s"${jobTitle} is ready",
subject = s"$jobTitle is ready",
bodyHtml = html.mail.jobSuccessfulGeneric(user.name, datasetName, jobLink, jobTitle, jobDescription).body,
recipients = List(userEmail)
)
Expand All @@ -184,7 +170,7 @@ class DefaultMails @Inject()(conf: WkConf) {
jobTitle: String): Mail =
Mail(
from = defaultSender,
subject = s"Your ${jobTitle} is ready",
subject = s"Your $jobTitle is ready",
bodyHtml = html.mail.jobSuccessfulSegmentation(user.name, datasetName, jobLink, jobTitle).body,
recipients = List(userEmail)
)
Expand Down
4 changes: 2 additions & 2 deletions app/models/user/UserService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class UserService @Inject()(conf: WkConf,
def joinOrganization(originalUser: User,
organizationId: ObjectId,
autoActivate: Boolean,
isAdmin: Boolean = false,
isAdmin: Boolean,
isUnlisted: Boolean = false,
isOrganizationOwner: Boolean = false): Fox[User] =
for {
Expand Down Expand Up @@ -232,7 +232,7 @@ class UserService @Inject()(conf: WkConf,
_ <- multiUserDAO.updatePasswordInfo(user._multiUser, passwordInfo)(GlobalAccessContext)
} yield passwordInfo

def getOpenIdConnectPasswordInfo: PasswordInfo =
private def getOpenIdConnectPasswordInfo: PasswordInfo =
PasswordInfo("Empty", "")

def updateUserConfiguration(user: User, configuration: JsObject)(implicit ctx: DBAccessContext): Fox[Unit] =
Expand Down
11 changes: 7 additions & 4 deletions app/models/user/time/TimeSpanService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import models.project.ProjectDAO
import models.task.TaskDAO
import models.user.{User, UserService}
import net.liftweb.common.Full
import thirdparty.BrainTracing
import org.apache.pekko.actor.{ActorSelection, ActorSystem}
import utils.{ObjectId, WkConf}

import scala.collection.mutable
Expand All @@ -23,17 +23,20 @@ import scala.concurrent.duration._
class TimeSpanService @Inject()(annotationDAO: AnnotationDAO,
userService: UserService,
taskDAO: TaskDAO,
brainTracing: BrainTracing,
annotationService: AnnotationService,
organizationService: OrganizationService,
projectDAO: ProjectDAO,
organizationDAO: OrganizationDAO,
timeSpanDAO: TimeSpanDAO,
defaultMails: DefaultMails,
conf: WkConf)(implicit ec: ExecutionContext)
conf: WkConf,
actorSystem: ActorSystem)(implicit ec: ExecutionContext)
extends FoxImplicits
with LazyLogging {

private lazy val Mailer: ActorSelection =
actorSystem.actorSelection("/user/mailActor")

def logUserInteraction(timestamp: Instant, user: User, annotation: Annotation)(
implicit ctx: DBAccessContext): Fox[Unit] =
logUserInteraction(Seq(timestamp), user, annotation)
Expand Down Expand Up @@ -180,7 +183,7 @@ class TimeSpanService @Inject()(annotationDAO: AnnotationDAO,
mailRecipient <- organizationService.overTimeMailRecipient(organization)(GlobalAccessContext)
} yield {
if (annotationTime >= timeLimit && annotationTime - time.toMillis < timeLimit) {
brainTracing.Mailer ! Send(defaultMails
Mailer ! Send(defaultMails
.overLimitMail(user, project.name, task._id.toString, annotation.id, List(mailRecipient, projectOwnerEmail)))
}
}
Expand Down
73 changes: 0 additions & 73 deletions app/thirdparty/BrainTracing.scala

This file was deleted.

11 changes: 0 additions & 11 deletions app/utils/WkConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,6 @@ class WkConf @Inject()(configuration: Configuration) extends ConfigReader with L
val workerLivenessTimeout: FiniteDuration = get[FiniteDuration]("jobs.workerLivenessTimeout")
}

object Braintracing {
val enabled: Boolean = get[Boolean]("braintracing.enabled")
val organizationName: String = get[String]("braintracing.organizationName")
val uri: String = get[String]("braintracing.uri")
val createUserScript: String = get[String]("braintracing.createUserScript")
val user: String = get[String]("braintracing.user")
val password: String = get[String]("braintracing.password")
val license: String = get[String]("braintracing.license")
}

object Airbrake {
val projectID: String = get[String]("airbrake.projectID")
val projectKey: String = get[String]("airbrake.projectKey")
Expand Down Expand Up @@ -268,7 +258,6 @@ class WkConf @Inject()(configuration: Configuration) extends ConfigReader with L
Mail,
Silhouette,
Jobs,
Braintracing,
Airbrake,
GoogleAnalytics,
BackendAnalytics,
Expand Down
Loading

0 comments on commit 29fddc6

Please sign in to comment.