From 21c3453e2537476e8bb8da4dfc885e6c5918ef1a Mon Sep 17 00:00:00 2001 From: Mario Garcia Date: Wed, 8 Jul 2020 06:16:38 +0200 Subject: [PATCH 1/3] feat(mail): refactor email service loading and docs --- CONTRIBUTING.md | 2 +- README.md | 39 +++++++---- etc/site/imgs/dwbh.png | Bin 4833 -> 0 bytes etc/site/imgs/patio.png | Bin 0 -> 3350 bytes .../services/internal/AwsSesMailService.java | 8 ++- .../services/internal/DummyEmailService.java | 64 ++++++++++++++++++ .../internal/RequiresAwsConfiguration.java | 33 +++++++++ .../internal/RequiresEmailConfiguration.java | 32 +++++++++ src/main/resources/application-prod.yml | 7 +- src/main/resources/application.yml.template | 7 +- src/main/resources/logback.xml | 2 +- 11 files changed, 170 insertions(+), 24 deletions(-) delete mode 100644 etc/site/imgs/dwbh.png create mode 100644 etc/site/imgs/patio.png create mode 100644 src/main/java/patio/infrastructure/email/services/internal/DummyEmailService.java create mode 100644 src/main/java/patio/infrastructure/email/services/internal/RequiresAwsConfiguration.java create mode 100644 src/main/java/patio/infrastructure/email/services/internal/RequiresEmailConfiguration.java diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd8535c..beb0856 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to DWBH +# Contributing to Patio We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: diff --git a/README.md b/README.md index 64639ea..e6abbfc 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ -[![Travis](https://travis-ci.org/dont-worry-be-happy/dwbh-api.svg?branch=master)](https://travis-ci.org/dont-worry-be-happy/dwbh-api) [![License](https://img.shields.io/github/license/dont-worry-be-happy/dwbh-api.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) +![API Continuos Integration](https://github.com/patio-team/patio-api/workflows/API%20Continuos%20Integration/badge.svg) ![Continuous deployment in dev](https://github.com/patio-team/patio-api/workflows/Continuous%20deployment%20in%20dev/badge.svg) [![License](https://img.shields.io/github/license/dont-worry-be-happy/dwbh-api.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) -# Don't Worry Be Happy +![dwbh](etc/site/imgs/patio.png) -![dwbh](etc/site/imgs/dwbh.png) - -**Don't Worry Be Happy** is a web application that tries to measure the happiness of a given team periodically by +**Patio** is a web application that tries to measure the happiness of a given team periodically by asking for a level of happiness between 1 and 5 (being 1 the saddest scenario and 5 the happiest). This repository hosts the backend of the DWBH project. Cool! @@ -164,8 +162,28 @@ And environment variables | DWBH_JDBC_PASSWORD | JDBC password | dwbh | | DWBH_JDBC_DRIVER | JDBC driver | org.postgresql.Driver | +##### EMAIL + +By default, if no other email service has been configured a default dummy service will be used to debug email mailing. You +can, for example, configure AWS credentials to enable AWS mailing service. + +```yaml +email: + source: ${DWBH_EMAIL_SOURCE} + enabled: ${DWBH_EMAIL_ENABLED} +``` + +And environment variables: + +| Name | Description | Default value | +|:---------------------------|:----------------------------|:--------------------------------------------------------------| +| DWBH_EMAIL_SOURCE | Source email | | +| DWBH_EMAIL_ENABLED | Enable mailing | | + ##### AWS integration +AWS credentials to use AWS services, such as AWS simple mail service. + Configuration file section: ```yaml @@ -173,10 +191,7 @@ aws: credentials: accessKey: ${DWBH_AWS_ACCESS_KEY} secretKey: ${DWBH_AWS_SECRET_KEY} - mail: - sourceemail: ${DWBH_AWS_EMAIL_SOURCE} - region: ${DWBH_AWS_EMAIL_REGION} - enabled: ${DWBH_AWS_EMAIL_ENABLED} + region: ${DWBH_AWS_REGION} ``` And environment variables: @@ -185,9 +200,7 @@ And environment variables: |:---------------------------|:----------------------------|:--------------------------------------------------------------| | DWBH_ACCESS_KEY | AWS access key | | | DWBH_SECRET_KEY | AWS secret key | | -| DWBH_AWS_EMAIL_SOURCE | AWS source email | | -| DWBH_AWS_EMAIL_REGION | AWS region | | -| DWBH_AWS_EMAIL_ENABLED | Enable AWS mailing | | +| DWBH_AWS_REGION | AWS region | | ##### JWT @@ -315,7 +328,7 @@ on this project are: ### Runtime * [Micronaut](https://micronaut.io/) - A JVM-based micro-framework -* [Jooq](https://www.jooq.org/) - Persistence framework +* [Micronaut Data](https://micronaut-projects.github.io/micronaut-data/latest/guide/) - Persistence framework * [AWS API](https://aws.amazon.com/sdk-for-java/) - For AWS services (e.g. mailing) ### Testing diff --git a/etc/site/imgs/dwbh.png b/etc/site/imgs/dwbh.png deleted file mode 100644 index a8eec80ae334a9b318a5a45275201f4f410f9d09..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4833 zcmbW5=Q|sK7RDoD&xBH`y*EWmDMDlKO{=I~yESXoCTfq;)`+e4t`%a>607#6HdUM8 z_WlR=xgXwhKAmspea`v42yIOzGGZt(001CUQHJaO>mmOYA^yJ_jZ1k806>aW;Bxvt z8T+sITplTXmYMqbt+>VMiiV)jijN3CJqGJI&B)Ix+tIB>c|(+Rl{&RgF(hmIgpObM zm}=$(^zC^t>LL5cVSK7EE(jq+RR50kSq;aoe017jMGudc-c-*n$-tqlS_K6&yUwC@ z;@MQw)UzTnZEXNR0fdMDe<)(OiU32>hFxEHZZAv$Q-iY50+80SK{o?1B7MSeVn7NJ z%LAn0EOV8jfH8yP!&0NqgQ=_j(HO&0t2}2uukCUa8kAx3ow=HHcv`* zV)@S%fqySG_i>>>2wP{~rneew*bh*}d?TxQ`GpEkLR2)Vf5Y#MdlAm4xMN@#_oI|0 zNtY}|*5%8OAFt0NIWeQwy37I~O0aU26(@t`{qOcWk3*r9&c3yiw;VxH0Qr>Qh6*Nv zd6ot`m;nrp)#80eFoxgg;qqK$UC8AjXZV(oV^y_5+HH%|7q|5v_vhA6t`Zd@jiW5) zaVfg1getHnwQTCd^a{wwSNmH5-#svdO;=jk&+qoM@o8{axk6}(+|JtF1A)!Lk1d@`gz%g*5SJOd7j{ zs9wG}*L!Z3JWCd#@Oo5l zsQKLi#i$I^9NM=V4YycbllR*6WDgE~xfs@dzoO~N4C0-1c>RpGViSG$%8K3Z#*-5V zNVcN3)oVJcQ|r4*;$F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_!p;$Vy$wE@T%yjO`;SY}2G6)cIdv4k5ZlCrR7 zt`&mKaf7X1T*Re8(?*(NCjxmZLrD9Jg|)@-3_t}db0aKeXrQSJjQ3L|)^UfX@9D;_; zdCz7BR)P{cbBCwBqk<`_f5tbuNAZ!}I$+n1btD-oI#p~DxJm$_JUX&QWGg|{jh0lH z#bFjEM*mlZ1Tm>;M2K1UKN@lcG*WRUkVZ`;wf%gDJHVpJtI8|(`_e3mzn^s{cQ^7p zD_lxAv~<$sAWnxz6GZw+4610lslhh-r`)Ve!ST9@ZJNPKD zZ^a|an|$d8y}%vpp*9n%uSeH~OrWDLCCi;0Rob}>l-uWY(Z z2$5BirYto#Uy40=@=1r~m{m-6XC-Lr5sm0LTi_b(3~dp3cOE!oZlL2^gb|iGdAX=W z_u{*vf0h1M-VISET$UfV74Diba=J0Ga4w#V)cDfCBHJ)w)14Q{-f}Y%wRlLx%g@of zAt6n0!d9ljl%cWB@QmKTK7xs3lk%aNt^vhtIwOhQ4_Fh|mt}iuKJj=&0PnbO&;*tT zX9EYd96!UEQxid$T$gFLhZpg+Aj(8y);~UV{vU#YO>~B;aGa-CDHXb(mKffCrHIcX zqYRq_2NNW90*x^bd6e_*nCfrcuFXOHTj3Ga*OHnt@%mJ9pzG=GD%F&P54jz#bM@)@ za3XbZ4y+C}m?O_q9)xdGwGFk;SLZi2psGZ!1bcv19z>A;A8F42k^n{AQvd+>_ooQU Vgni_;=)dR+prW7&uaLJ0`48RX6UG1l diff --git a/etc/site/imgs/patio.png b/etc/site/imgs/patio.png new file mode 100644 index 0000000000000000000000000000000000000000..a670d9359d2298d450e8f5816d4590ed560b70fc GIT binary patch literal 3350 zcmb7G=QkS;8;u#`XH~3L)v8sih^@8vCT8s!q|`1_#3-St5wm7%#HgZ5&6a9o@6-yl z8zZPy^YuID{R7_jJm)_5ocry0?)`8RjSaPEsBTjM000^tZFSQd_W2hSmsTu32sd4)G`?^DY+yDT9*YMX$+C9qb-yCecHPE!d^uNnSE zY=X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D6I}c=vm7#LyxK$bM~euYxV4hZ@-N-ohc05v z3U}6KSRIy%cqjiMxfJES%*g&E;;+qFq?)i_EjwB_d8P#s`H4)7cU^dbTzw$P}n)aljD$V2Z zP+}e{M(aZrlQi6Ly@h4@my?ZFedLS!x~+OKvsw@q024zVC3m|}{Nl}(oQ<5VgyYel zim-vOY~EWdyNAGys-a*UNP&>H!4@>%Het8=dtz1 zk(NKFhw|8kxn_D9jg_6~eebxX>LP8orO#M_pp>VSWi2KnYqiD|otH=&L~sX1@1Hh% uZkg?qHS7Mm*clf7e|qMB8|eygxr?cbTgs0Q1iNX>038iO^*U8Y#D4$?-evp% literal 0 HcmV?d00001 diff --git a/src/main/java/patio/infrastructure/email/services/internal/AwsSesMailService.java b/src/main/java/patio/infrastructure/email/services/internal/AwsSesMailService.java index 9d8a521..c8c5f27 100644 --- a/src/main/java/patio/infrastructure/email/services/internal/AwsSesMailService.java +++ b/src/main/java/patio/infrastructure/email/services/internal/AwsSesMailService.java @@ -41,6 +41,8 @@ */ @Singleton @Primary +@RequiresAwsConfiguration +@RequiresEmailConfiguration @SuppressWarnings("all") public class AwsSesMailService implements EmailService { private static final Logger LOG = LoggerFactory.getLogger(AwsSesMailService.class); @@ -64,9 +66,9 @@ public class AwsSesMailService implements EmailService { */ public AwsSesMailService( AWSCredentialsProvider credentialsProvider, - @Value("${aws.mail.enabled}") boolean emailEnabled, - @Value("${aws.mail.region:none}") String awsRegion, - @Value("${aws.mail.sourceemail:none}") String sourceEmail) { + @Value("${email.enabled}") boolean emailEnabled, + @Value("${aws.credentials.region:none}") String awsRegion, + @Value("${email.source:none}") String sourceEmail) { this.credentialsProvider = credentialsProvider; this.emailEnabled = emailEnabled; this.awsRegion = awsRegion; diff --git a/src/main/java/patio/infrastructure/email/services/internal/DummyEmailService.java b/src/main/java/patio/infrastructure/email/services/internal/DummyEmailService.java new file mode 100644 index 0000000..47007de --- /dev/null +++ b/src/main/java/patio/infrastructure/email/services/internal/DummyEmailService.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2019 Kaleidos Open Source SL + * + * This file is part of Don't Worry Be Happy (DWBH). + * DWBH is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DWBH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DWBH. If not, see + */ +package patio.infrastructure.email.services.internal; + +import io.micronaut.context.annotation.Value; +import javax.inject.Singleton; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import patio.infrastructure.email.domain.Email; +import patio.infrastructure.email.services.EmailService; + +/** + * Default email implementation. It just works as a placeholder when no other email service has been + * configured + */ +@Singleton +public class DummyEmailService implements EmailService { + + private static final Logger LOG = LoggerFactory.getLogger(DummyEmailService.class); + + private final boolean emailEnabled; + + /** + * Inits the service checking whether the emails should be sent or not + * + * @param emailEnabled whether emails should be sent or not + */ + public DummyEmailService(@Value("mail.enabled") boolean emailEnabled) { + this.emailEnabled = emailEnabled; + } + + @Override + public void send(Email email) { + if (this.emailEnabled) { + LOG.debug("emulate sending an email"); + } else { + LOG.debug("email service disabled"); + } + } + + /** + * Whether emails should be sent or not + * + * @return whether emails should be sent or not + */ + public boolean isEmailEnabled() { + return emailEnabled; + } +} diff --git a/src/main/java/patio/infrastructure/email/services/internal/RequiresAwsConfiguration.java b/src/main/java/patio/infrastructure/email/services/internal/RequiresAwsConfiguration.java new file mode 100644 index 0000000..608cf03 --- /dev/null +++ b/src/main/java/patio/infrastructure/email/services/internal/RequiresAwsConfiguration.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2019 Kaleidos Open Source SL + * + * This file is part of Don't Worry Be Happy (DWBH). + * DWBH is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DWBH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DWBH. If not, see + */ +package patio.infrastructure.email.services.internal; + +import io.micronaut.context.annotation.Requires; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.PACKAGE, ElementType.TYPE}) +@Requires(property = "aws.credentials.accesskey") +@Requires(property = "aws.credentials.secretkey") +@Requires(property = "aws.credentials.region") +public @interface RequiresAwsConfiguration {} diff --git a/src/main/java/patio/infrastructure/email/services/internal/RequiresEmailConfiguration.java b/src/main/java/patio/infrastructure/email/services/internal/RequiresEmailConfiguration.java new file mode 100644 index 0000000..716bcdf --- /dev/null +++ b/src/main/java/patio/infrastructure/email/services/internal/RequiresEmailConfiguration.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2019 Kaleidos Open Source SL + * + * This file is part of Don't Worry Be Happy (DWBH). + * DWBH is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DWBH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DWBH. If not, see + */ +package patio.infrastructure.email.services.internal; + +import io.micronaut.context.annotation.Requires; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.PACKAGE, ElementType.TYPE}) +@Requires(property = "email.enabled") +@Requires(property = "email.source") +public @interface RequiresEmailConfiguration {} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 88f1ef6..90d560e 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -56,10 +56,11 @@ aws: credentials: accesskey: ${DWBH_AWS_ACCESS_KEY} secretkey: ${DWBH_AWS_SECRET_KEY} - mail: - sourceemail: ${DWBH_AWS_EMAIL_SOURCE} region: ${DWBH_AWS_EMAIL_REGION} - enabled: ${DWBH_AWS_EMAIL_ENABLED} + +email: + enabled: ${DWBH_EMAIL_ENABLED} + source: ${DWBH_EMAIL_SOURCE} crypto: password: SHA-256 diff --git a/src/main/resources/application.yml.template b/src/main/resources/application.yml.template index e35c038..8dd9461 100644 --- a/src/main/resources/application.yml.template +++ b/src/main/resources/application.yml.template @@ -56,11 +56,12 @@ aws: credentials: accesskey: XXX secretkey: YYY - mail: - enabled: false - sourceemail: noreply@dwbh.com region: eu-west-1 +email: + enabled: false + source: noreply@dwbh.com + crypto: jwt: secret: secret diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 310f6c1..ee8f346 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -36,7 +36,7 @@ --> - + From f807c59d8df6fe5e2eb3237d98f8240f237cf5b7 Mon Sep 17 00:00:00 2001 From: Mario Garcia Date: Thu, 9 Jul 2020 11:10:32 +0200 Subject: [PATCH 2/3] fix(log): hibernate sql configuration now only depends on logback.xml --- .../email/services/internal/DummyEmailService.java | 2 +- src/main/resources/application-prod.yml | 1 - src/main/resources/application.yml.template | 1 - src/main/resources/logback.xml | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/patio/infrastructure/email/services/internal/DummyEmailService.java b/src/main/java/patio/infrastructure/email/services/internal/DummyEmailService.java index 47007de..2462751 100644 --- a/src/main/java/patio/infrastructure/email/services/internal/DummyEmailService.java +++ b/src/main/java/patio/infrastructure/email/services/internal/DummyEmailService.java @@ -40,7 +40,7 @@ public class DummyEmailService implements EmailService { * * @param emailEnabled whether emails should be sent or not */ - public DummyEmailService(@Value("mail.enabled") boolean emailEnabled) { + public DummyEmailService(@Value("${email.enabled}") boolean emailEnabled) { this.emailEnabled = emailEnabled; } diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 90d560e..d536381 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -39,7 +39,6 @@ jpa: default: properties: hibernate: - show_sql: false # dialect: org.hibernate.dialect.PostgreSQL95Dialect flyway: diff --git a/src/main/resources/application.yml.template b/src/main/resources/application.yml.template index 8dd9461..a72c5eb 100644 --- a/src/main/resources/application.yml.template +++ b/src/main/resources/application.yml.template @@ -39,7 +39,6 @@ jpa: default: properties: hibernate: - show_sql: true # dialect: org.hibernate.dialect.PostgreSQL95Dialect flyway: diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index ee8f346..ca89e42 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -38,7 +38,7 @@ --> - + \ No newline at end of file From 4ce180240879e3063939f5bfdf4ce98af1da509c Mon Sep 17 00:00:00 2001 From: Mario Garcia Date: Thu, 9 Jul 2020 11:56:22 +0200 Subject: [PATCH 3/3] fix(log): add minimal logging in README --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index e6abbfc..7400ea6 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,31 @@ fixtures { } ``` +## Logging + +All logging configuration can be found in the `logback.xml` file. By default + +```xml + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + +``` + +If you'd like to activate SQL queries you can use the following loggers: + +```xml + + +``` + ## Technologies The most important technologies you need to be aware of to work