Commit ffdee7d1 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Add var env to be able to send the feedback to many email address

parent fff9d45c
Pipeline #2457 passed with stages
in 5 minutes and 11 seconds
......@@ -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
......
......@@ -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:
......
{
"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
......@@ -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() {
......
......@@ -14,4 +14,5 @@ export const config = {
groupHeader: '',
mailSubjectPrefix: '',
noReplyMailAddress: '',
additionalFeedbackEmails: '',
};
\ No newline at end of file
......@@ -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
......@@ -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;
......
{"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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment