Skip to content

Commit 91acb08

Browse files
authored
Merge pull request #4 from SOFTNETWORK-APP/feature/coverage
Feature/coverage
2 parents e99e4e2 + c1349f9 commit 91acb08

File tree

79 files changed

+2429
-614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2429
-614
lines changed

api/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import app.softnetwork.sbt.build._
22
import com.typesafe.sbt.packager.docker._
33

4-
Compile / mainClass := Some("app.softnetwork.notification.api.NotificationPostgresLauncher")
4+
Compile / mainClass := Some("app.softnetwork.notification.api.AllNotificationsPostgresLauncher")
55

66
dockerBaseImage := "openjdk:8"
77

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package app.softnetwork.notification.api
22

33
import akka.actor.typed.ActorSystem
4-
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
5-
import app.softnetwork.notification.handlers.NotificationHandler
4+
import app.softnetwork.notification.handlers.AllNotificationsHandler
65
import app.softnetwork.notification.launch.NotificationApplication
76
import app.softnetwork.notification.model.Notification
87
import app.softnetwork.notification.persistence.query.{
@@ -16,19 +15,17 @@ import app.softnetwork.notification.persistence.typed.{
1615
import app.softnetwork.persistence.jdbc.query.{JdbcJournalProvider, JdbcSchema, JdbcSchemaProvider}
1716
import app.softnetwork.scheduler.api.SchedulerApi
1817

19-
import scala.concurrent.Future
18+
trait AllNotificationsApi extends SchedulerApi with NotificationApplication[Notification] {
2019

21-
trait NotificationApi extends SchedulerApi with NotificationApplication {
22-
23-
override def notificationBehavior: ActorSystem[_] => Option[NotificationBehavior[Notification]] =
24-
_ => Some(AllNotificationsBehavior)
20+
override def notificationBehaviors: ActorSystem[_] => Seq[NotificationBehavior[Notification]] =
21+
_ => Seq(AllNotificationsBehavior)
2522

2623
override def scheduler2NotificationProcessorStream
2724
: ActorSystem[_] => Option[Scheduler2NotificationProcessorStream] =
2825
sys =>
2926
Some(
3027
new Scheduler2NotificationProcessorStream()
31-
with NotificationHandler
28+
with AllNotificationsHandler
3229
with JdbcJournalProvider
3330
with JdbcSchemaProvider {
3431
override val tag = s"${AllNotificationsBehavior.persistenceId}-scheduler"
@@ -42,17 +39,17 @@ trait NotificationApi extends SchedulerApi with NotificationApplication {
4239
sys =>
4340
Some(
4441
new NotificationCommandProcessorStream
45-
with NotificationHandler
42+
with AllNotificationsHandler
4643
with JdbcJournalProvider
4744
with JdbcSchemaProvider {
4845
override lazy val schemaType: JdbcSchema.SchemaType = jdbcSchemaType
4946
override implicit def system: ActorSystem[_] = sys
5047
}
5148
)
5249

53-
override def grpcServices
54-
: ActorSystem[_] => Seq[PartialFunction[HttpRequest, Future[HttpResponse]]] = system =>
55-
Seq(
56-
NotificationServiceApiHandler.partial(NotificationServer(system))(system)
57-
)
50+
/** initialize all notification servers
51+
*/
52+
override def notificationServers: ActorSystem[_] => Seq[NotificationServer] = sys =>
53+
Seq(AllNotificationsServer(sys))
54+
5855
}

api/src/main/scala/app/softnetwork/notification/api/NotificationPostgresLauncher.scala renamed to api/src/main/scala/app/softnetwork/notification/api/AllNotificationsPostgresLauncher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package app.softnetwork.notification.api
22

33
import app.softnetwork.persistence.jdbc.query.PostgresSchemaProvider
44

5-
object NotificationPostgresLauncher extends NotificationApi with PostgresSchemaProvider
5+
object AllNotificationsPostgresLauncher extends AllNotificationsApi with PostgresSchemaProvider

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ThisBuild / organization := "app.softnetwork"
3131

3232
name := "notification"
3333

34-
ThisBuild / version := "0.1.2"
34+
ThisBuild / version := "0.1-SNAPSHOT"
3535

3636
ThisBuild / scalaVersion := "2.12.15"
3737

common/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ libraryDependencies ++= Seq(
1616
"com.google.auth" % "google-auth-library-oauth2-http" % "0.20.0" excludeAll guavaExclusion,
1717
"io.opencensus" % "opencensus-contrib-http-util" % "0.24.0" excludeAll(guavaExclusion, ExclusionRule(organization = "io.grpc", name="grpc-context")),
1818
"com.google.firebase" % "firebase-admin" % "7.1.0" excludeAll(ExclusionRule(organization = "io.opencensus", name="opencensus-contrib-http-util"), ExclusionRule(organization = "com.google.auth", name = "google-auth-library-oauth2-http")/*, ExclusionRule(organization = "org.apache.commons", name = "commons-lang3")*/, ExclusionRule(organization = "io.netty")),
19-
"com.eatthepath" % "pushy" % "0.14.2"
19+
"com.eatthepath" % "pushy" % "0.15.1"
2020
)
2121

2222
Compile / unmanagedResourceDirectories += baseDirectory.value / "src/main/protobuf"

common/src/main/protobuf/model/notifications.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ message NotificationStatusResult {
3838
required string recipient = 1;
3939
required NotificationStatus status = 2;
4040
optional string error = 3;
41+
optional string uuid = 4;
4142
}
4243

4344
message NotificationAck {
Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,7 @@
11
notification {
22
akka-node-role = notifications
3-
mail {
4-
host = "smtp.gmail.com"
5-
host = ${?MAIL_HOST}
6-
port = 465
7-
port = ${?MAIL_PORT}
8-
sslPort = 465
9-
sslPort = ${?MAIL_SSL_PORT}
10-
sslEnabled = true
11-
sslEnabled = ${?MAIL_SSL_ENABLED}
12-
sslCheckServerIdentity = false
13-
sslCheckServerIdentity = ${?MAIL_CHECK_SERVER_IDENTITY}
14-
startTLSEnabled = false
15-
startTLSEnabled = ${?MAIL_START_TLS_ENABLED}
16-
socketConnectionTimeout = 2000
17-
socketTimeout = 2000
18-
19-
from = ${credentials.mail.username}
20-
from = ${?NOTIFICATION_MAIL_FROM}
21-
name = "nobody"
22-
name = ${?NOTIFICATION_MAIL_NAME}
23-
username = ${credentials.mail.username}
24-
password = ${credentials.mail.password}
25-
}
26-
27-
push {
28-
apns {
29-
topic = ""
30-
topic = ${?NOTIFICATION_PUSH_APNS_TOPIC}
31-
32-
keystore {
33-
path = ""
34-
path = ${?NOTIFICATION_PUSH_APNS_KEYSTORE_PATH}
35-
password = ""
36-
password = ${?NOTIFICATION_PUSH_APNS_KEYSTORE_PASSWORD}
37-
}
38-
39-
dry-run = false
40-
dry-run = ${?NOTIFICATION_PUSH_APNS_DRY_RUN}
41-
}
42-
43-
fcm {
44-
databaseUrl = ""
45-
databaseUrl = ${?NOTIFICATION_PUSH_FCM_DATABASE_URL}
46-
google-credentials = ""
47-
google-credentials = ${?GOOGLE_APPLICATION_CREDENTIALS}
48-
}
49-
50-
apps = []
51-
52-
}
53-
54-
sms {
55-
mode {
56-
access-token = ""
57-
access-token = ${?NOTIFICATION_SMS_MODE_ACCESS_TOKEN}
58-
base-url = "https://api.smsmode.com/http"
59-
version = "1.6"
60-
}
61-
}
623

634
event-streams {
645
external-to-notification-tag = "external-to-notification"
656
}
667
}
67-
68-
credentials{
69-
mail{
70-
username = "nobody@gmail.com"
71-
username = ${?CREDENTIALS_MAIL_USERNAME}
72-
password = "changeit"
73-
password = ${?CREDENTIALS_MAIL_PASSWORD}
74-
}
75-
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package app.softnetwork.notification.config
2+
3+
import com.typesafe.config.{Config, ConfigFactory}
4+
5+
trait InternalConfig {
6+
def config: Config
7+
}
8+
9+
trait DefaultConfig extends InternalConfig {
10+
lazy val config: Config = ConfigFactory.load()
11+
}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
package app.softnetwork.notification.config
22

3-
import com.typesafe.config.{Config, ConfigFactory}
43
import com.typesafe.scalalogging.StrictLogging
54
import configs.Configs
65

7-
import scala.language.implicitConversions
8-
9-
trait NotificationSettings extends StrictLogging {
10-
11-
lazy val config: Config = ConfigFactory.load()
6+
import scala.language.{implicitConversions, reflectiveCalls}
127

8+
trait NotificationSettings extends StrictLogging { _: InternalConfig =>
139
lazy val NotificationConfig: NotificationConfig =
1410
Configs[NotificationConfig].get(config, "notification").toEither match {
1511
case Left(configError) =>
@@ -20,4 +16,4 @@ trait NotificationSettings extends StrictLogging {
2016

2117
}
2218

23-
object NotificationSettings extends NotificationSettings
19+
object NotificationSettings extends NotificationSettings with DefaultConfig

common/src/main/scala/app/softnetwork/notification/message/package.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package app.softnetwork.notification
33
import app.softnetwork.persistence.message._
44
import org.softnetwork.akka.model.Schedule
55
import app.softnetwork.notification.model.Notification
6+
import org.softnetwork.notification.model.NotificationStatusResult
67

78
/** Created by smanciot on 15/04/2020.
89
*/
@@ -44,13 +45,16 @@ package object message {
4445
case object NotificationRemoved extends NotificationCommandResult
4546

4647
@SerialVersionUID(0L)
47-
case class NotificationSent(uuid: String) extends NotificationCommandResult
48+
case class NotificationSent(uuid: String, results: Seq[NotificationStatusResult])
49+
extends NotificationCommandResult
4850

4951
@SerialVersionUID(0L)
50-
case class NotificationDelivered(uuid: String) extends NotificationCommandResult
52+
case class NotificationDelivered(uuid: String, results: Seq[NotificationStatusResult])
53+
extends NotificationCommandResult
5154

5255
@SerialVersionUID(0L)
53-
case class NotificationPending(uuid: String) extends NotificationCommandResult
56+
case class NotificationPending(uuid: String, results: Seq[NotificationStatusResult])
57+
extends NotificationCommandResult
5458

5559
case class Schedule4NotificationTriggered(schedule: Schedule) extends NotificationCommandResult
5660

@@ -60,11 +64,11 @@ package object message {
6064
with NotificationCommandResult
6165

6266
@SerialVersionUID(0L)
63-
case class NotificationUndelivered(uuid: String)
64-
extends NotificationErrorMessage("NotificationNotDelivered")
67+
case class NotificationUndelivered(uuid: String, results: Seq[NotificationStatusResult])
68+
extends NotificationErrorMessage("NotificationUndelivered")
6569

6670
@SerialVersionUID(0L)
67-
case class NotificationRejected(uuid: String)
71+
case class NotificationRejected(uuid: String, results: Seq[NotificationStatusResult])
6872
extends NotificationErrorMessage("NotificationRejected")
6973

7074
case object NotificationNotFound extends NotificationErrorMessage("NotificationNotFound")

0 commit comments

Comments
 (0)