Skip to content

Commit

Permalink
Debug email sending for different versions (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek authored Jun 6, 2024
1 parent eaa82ea commit 0fbee51
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
20 changes: 10 additions & 10 deletions api/app/actors/Emails.scala → api/app/lib/Emails.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package actors
package lib

import db.{ApplicationsDao, Authorization, MembershipsDao, SubscriptionsDao}
import io.apibuilder.api.v0.models._
import lib._
import org.joda.time.DateTime
import play.api.Logging

import javax.inject.{Inject, Singleton}
Expand Down Expand Up @@ -46,13 +46,13 @@ class Emails @Inject() (
implicit filter: Subscription => Boolean = { _ => true }
): Unit = {
eachSubscription(context, org, publication, { subscription =>
if (filter(subscription)) {
email.sendHtml(
to = Person(subscription.user),
subject = subject,
body = body
)
}
val result = filter(subscription)
println(s"[${DateTime.now} DEBUG_FILTER] result: $result")
email.sendHtml(
to = Person(subscription.user),
subject = subject,
body = body
)
})
}

Expand Down Expand Up @@ -80,7 +80,7 @@ class Emails @Inject() (
}
}

private[actors] def isAuthorized(
private[lib] def isAuthorized(
context: Emails.Context,
organization: Organization,
user: User
Expand Down
1 change: 0 additions & 1 deletion api/app/processor/CheckInvariantsProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class CheckInvariantsProcessor @Inject()(
private[this] def sendResults(results: Seq[InvariantResult]): Unit = {
val (noErrors, withErrors) = results.partition(_.count == 0)

println(s"# Invariants checked with no errors: ${noErrors.length}")
if (withErrors.nonEmpty) {
lazy val subject = if (withErrors.length == 1) {
"1 Error"
Expand Down
3 changes: 1 addition & 2 deletions api/app/processor/DiffVersionProcessor.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package processor

import actors.Emails
import cats.data.ValidatedNec
import cats.implicits._
import db._
import io.apibuilder.api.v0.models._
import io.apibuilder.task.v0.models.json._
import io.apibuilder.task.v0.models.{DiffVersionData, TaskType}
import lib.{AppConfig, ServiceDiff}
import lib.{AppConfig, ServiceDiff, Emails}
import play.twirl.api.Html

import java.util.UUID
Expand Down
3 changes: 1 addition & 2 deletions api/app/processor/EmailProcessor.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package processor

import actors.Emails
import cats.data.ValidatedNec
import cats.implicits._
import db.{Authorization, InternalTasksDao, OrganizationsDao, UsersDao}
import io.apibuilder.api.v0.models.Publication
import io.apibuilder.task.v0.models._
import io.apibuilder.task.v0.models.json._
import lib.{AppConfig, EmailUtil, Person, Role}
import lib.{AppConfig, EmailUtil, Person, Emails, Role}
import play.api.libs.json.Json

import java.sql.Connection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package actors
package lib

import io.apibuilder.api.v0.models.Visibility
import lib.Role
import org.scalatestplus.play.PlaySpec
import org.scalatestplus.play.guice.GuiceOneAppPerSuite

Expand Down
7 changes: 3 additions & 4 deletions api/test/util/Daos.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package util

import actors.Emails
import db._
import db.generated.SessionsDao
import db.generators.{GeneratorsDao, ServicesDao}
import db._
import lib.DatabaseServiceFetcher
import lib.{DatabaseServiceFetcher, Emails}
import play.api.Application
import play.api.inject.Injector

Expand Down Expand Up @@ -38,7 +37,7 @@ trait Daos {
def servicesDao: ServicesDao = injector.instanceOf[db.generators.ServicesDao]
def generatorsDao: GeneratorsDao = injector.instanceOf[db.generators.GeneratorsDao]

def emails: Emails = injector.instanceOf[actors.Emails]
def emails: Emails = injector.instanceOf[Emails]

def sessionHelper: SessionHelper = injector.instanceOf[SessionHelper]
}

0 comments on commit 0fbee51

Please sign in to comment.