diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8ac72cee87fcdfdd5dba6b688aaf3ec0b72d3dfa..7eb4a640b58b5f042b770492ec44c8ae59b51797 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ stages: variables: USER_SUPPORT_MAILBOX: alpha-test@erasme.org + ADDITIONAL_FEEDBACK_EMAILS: fabien.forestier@soprasteria.com,castejon.nicolas@gmail.com,florent.dufier@gmail.com build_development: stage: build diff --git a/docker-compose.yml b/docker-compose.yml index 978d0694e1a3d7a4e6c35fe22c85f10fa802cd26..eae8767b5d6dcb82bc4bf784db0935d9209e0690 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: - EMAIL_WRITER_GROUP_NAME=email-writer - MAIL_SUBJECT_PREFIX=${MAIL_SUBJECT_PREFIX} - NO_REPLY_MAIL_ADDRESS=${NO_REPLY_MAIL_ADDRESS} + - ADDITIONAL_FEEDBACK_EMAILS=${ADDITIONAL_FEEDBACK_EMAILS} restart: unless-stopped rabbitmq: diff --git a/package.json b/package.json index 64c37b44fa28cba07a21a9db06d0cb4d62721b8a..8053cc6800e6d4b72b3796dafc529640e8bf7284 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "service-email", - "version": "1.1.1", + "version": "1.1.2", "description": "description", "author": "", "license": "MIT", @@ -68,4 +68,4 @@ "coverageDirectory": "../coverage", "testEnvironment": "node" } -} +} \ No newline at end of file diff --git a/src/configuration/config.service.ts b/src/configuration/config.service.ts index 80c8f4bcc8d34d56e1d2e5994164374054f35113..193cb34e40778466042770dacf2f45e57045c8f9 100644 --- a/src/configuration/config.service.ts +++ b/src/configuration/config.service.ts @@ -25,6 +25,7 @@ export class ConfigService { this._config.groupHeader = process.env.GROUP_HEADER; this._config.mailSubjectPrefix = process.env.MAIL_SUBJECT_PREFIX; this._config.noReplyMailAddress = process.env.NO_REPLY_MAIL_ADDRESS; + this._config.additionalFeedbackEmails = process.env.ADDITIONAL_FEEDBACK_EMAILS; } get config() { diff --git a/src/configuration/config.ts b/src/configuration/config.ts index b842d19ff8f221333e64e40ab9f15e7660be3d74..7f1ddb76a9c3dec3da7d16b6383aa38b00c53076 100644 --- a/src/configuration/config.ts +++ b/src/configuration/config.ts @@ -14,4 +14,5 @@ export const config = { groupHeader: '', mailSubjectPrefix: '', noReplyMailAddress: '', + additionalFeedbackEmails: '', }; \ No newline at end of file diff --git a/src/configuration/template.env b/src/configuration/template.env index 06f4d17b46e29857e72036190e99eb03ccd38644..ae1b2ebfc44c4e3374251296cefbe2472519b354 100644 --- a/src/configuration/template.env +++ b/src/configuration/template.env @@ -2,4 +2,7 @@ RABBITMQ_USER= RABBITMQ_PASSWORD= USER_SUPPORT_MAILBOX= MAIL_SUBJECT_PREFIX= -NO_REPLY_MAIL_ADDRESS= \ No newline at end of file +NO_REPLY_MAIL_ADDRESS= +ADDITIONAL_FEEDBACK_EMAILS= +GROUP_HEADER= +EMAIL_WRITER_GROUP_NAME= \ No newline at end of file diff --git a/src/email/email.service.ts b/src/email/email.service.ts index 26b4bbebd6c00692daba1231e27854ea7c4a2abb..e78709ffed7e3006e911b46e01608cfffb2b0f3c 100644 --- a/src/email/email.service.ts +++ b/src/email/email.service.ts @@ -76,6 +76,11 @@ export class EmailService { }); const feedbackEmail = new EmailWithoutFrom(); feedbackEmail.to = [this.config.userSupportMailbox]; + + if (this.config.additionalFeedbackEmails) { + feedbackEmail.to = feedbackEmail.to.concat(this.config.additionalFeedbackEmails.split(',')); + } + feedbackEmail.subject = 'Feedback'; feedbackEmail.html = feedbackEmailBody; diff --git a/swagger-spec.json b/swagger-spec.json index c3eeaa52b35ab17fe14e80cb262345f2971b9a59..c47056c863dfcac93cd1422ae9f2a340febb76d5 100644 --- a/swagger-spec.json +++ b/swagger-spec.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"description":"Service providing the method to send emails.","version":"0.1","title":"Email service API"},"basePath":"/","tags":[{"name":"email","description":""}],"schemes":["http"],"paths":{"/email/contact":{"post":{"summary":"Send email to admin (emails defined as var env of the project, see docker-compose.yml file) and recap email to user email.","parameters":[{"name":"ContactForm","required":true,"in":"body","schema":{"$ref":"#/definitions/ContactForm"}}],"responses":{"200":{"description":"OK"},"400":{"description":"Missing fields"},"500":{"description":"Internal error, this is probably a rabbitMQ related error (unreachable service...)"}},"tags":["email"],"produces":["application/json"],"consumes":["application/json"]}},"/email/feedback":{"post":{"summary":"Send email to admin with the user feedback","parameters":[{"name":"FeedbackForm","required":true,"in":"body","schema":{"$ref":"#/definitions/FeedbackForm"}}],"responses":{"200":{"description":"OK"},"400":{"description":"Missing fields"},"500":{"description":"Internal error, this is probably a rabbitMQ related error (unreachable service...)"}},"tags":["email"],"produces":["application/json"],"consumes":["application/json"]}},"/email/send":{"post":{"summary":"Send email.","parameters":[{"name":"EmailWithoutFrom","required":true,"in":"body","schema":{"$ref":"#/definitions/EmailWithoutFrom"}}],"responses":{"200":{"description":"OK"},"400":{"description":"Missing fields"},"500":{"description":"Internal error, this is probably a rabbitMQ related error (unreachable service...)"}},"tags":["email"],"produces":["application/json"],"consumes":["application/json"]}}},"definitions":{"ContactForm":{"type":"object","properties":{"email":{"type":"string"},"subject":{"type":"string"},"firstname":{"type":"string"},"lastname":{"type":"string"},"text":{"type":"string"}},"required":["email","subject","firstname","lastname","text"]},"FeedbackForm":{"type":"object","properties":{"url":{"type":"string"},"version":{"type":"string"},"message":{"type":"string"}},"required":["url","version","message"]},"EmailWithoutFrom":{"type":"object","properties":{"to":{"type":"array","items":{"type":"string"}},"replyTo":{"type":"string"},"cc":{"type":"array","items":{"type":"string"}},"bcc":{"type":"array","items":{"type":"string"}},"subject":{"type":"string"},"html":{"type":"string"}},"required":["to","subject","html"]}}} \ No newline at end of file +{"swagger":"2.0","info":{"description":"Service providing the method to send emails.","version":"0.1","title":"Email service API"},"basePath":"/","tags":[{"name":"email","description":""}],"schemes":["http"],"paths":{"/contact":{"post":{"summary":"Send email to admin (emails defined as var env of the project, see docker-compose.yml file) and recap email to user email.","parameters":[{"name":"ContactForm","required":true,"in":"body","schema":{"$ref":"#/definitions/ContactForm"}}],"responses":{"200":{"description":"OK"},"400":{"description":"Missing fields"},"500":{"description":"Internal error, this is probably a rabbitMQ related error (unreachable service...)"}},"produces":["application/json"],"consumes":["application/json"]}},"/feedback":{"post":{"summary":"Send email to admin with the user feedback","parameters":[{"name":"FeedbackForm","required":true,"in":"body","schema":{"$ref":"#/definitions/FeedbackForm"}}],"responses":{"200":{"description":"OK"},"400":{"description":"Missing fields"},"500":{"description":"Internal error, this is probably a rabbitMQ related error (unreachable service...)"}},"produces":["application/json"],"consumes":["application/json"]}},"/send":{"post":{"summary":"Send email.","parameters":[{"name":"EmailWithoutFrom","required":true,"in":"body","schema":{"$ref":"#/definitions/EmailWithoutFrom"}}],"responses":{"200":{"description":"OK"},"400":{"description":"Missing fields"},"500":{"description":"Internal error, this is probably a rabbitMQ related error (unreachable service...)"}},"produces":["application/json"],"consumes":["application/json"]}}},"definitions":{"ContactForm":{"type":"object","properties":{"email":{"type":"string"},"subject":{"type":"string"},"firstname":{"type":"string"},"lastname":{"type":"string"},"text":{"type":"string"}},"required":["email","subject","firstname","lastname","text"]},"FeedbackForm":{"type":"object","properties":{"url":{"type":"string"},"version":{"type":"string"},"message":{"type":"string"}},"required":["url","version","message"]},"EmailWithoutFrom":{"type":"object","properties":{"to":{"type":"array","items":{"type":"string"}},"replyTo":{"type":"string"},"cc":{"type":"array","items":{"type":"string"}},"bcc":{"type":"array","items":{"type":"string"}},"subject":{"type":"string"},"html":{"type":"string"}},"required":["to","subject","html"]}}} \ No newline at end of file