diff --git a/README.md b/README.md index 0b2816d2c064a10c78690b3dceef0b0ff4a21613..33090e9c6e6abb032682efd82a794e359cebaa29 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,18 @@ log_out is a method that sends a delete http request containing the JWT token of session[:logged_in] is set to false by this method +## Mailer Microservice + +The Mailer Microservice is run inside a docker container that is booted up by using [this](#creating-the-image) command. + +### Helper Methods + +There are a few Helper Methods that in the ApplicationController.rb file, which means the methods are available to any controller that inherits from ApplicationController (i.e most controllers). + +#### reminder_email + +reminder_email(emails, reminder) is a method that takes two inputs, emails and reminder, emails is a list of emails that the reminder needs to be sent to, and the reminder input is a reminder object (currently no model exists, need to implement when reminders are added to the database). + ## Adding to the readme When editing use this as a guide: https://guides.github.com/features/mastering-markdown/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3481e2b7714c8f6f42dda76d084b3bd483478424..1fefd03b2c15809dac67a38183f579678e5cecf7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -65,4 +65,15 @@ class ApplicationController < ActionController::Base redirect_to root_path end + def reminder_email(emails, reminder) + email = HTTParty.post('http://172.17.0.1:3002/reminder', :body => { + :emails => emails, + :event => { + :title => reminder["title"], + :description => reminder["description"] + } + }) + redirect_to root_path + end + end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index bed6ba7e98836c25f6a26e40241952ba16a3fe16..17d45a629252c406a29b3153134bf9191fc46263 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -28,6 +28,13 @@ class HomeController < ApplicationController def test_auth auth end + + def reminder_email_test + email = ["rtreadwaynest@gmail.com", "ross@alantreadway.net"] + reminder = {"title" => "this is a test", "description" => "this is a test description"} + reminder_email(email, reminder) + end + end \ No newline at end of file diff --git a/app/views/home/home.html.erb b/app/views/home/home.html.erb index ddc973bb2777a6af4ae48d5df602afd07d324ebf..7472d19bf6374ca6a766dc604bbdd647d1ea95c5 100644 --- a/app/views/home/home.html.erb +++ b/app/views/home/home.html.erb @@ -12,6 +12,7 @@ <body> <%= yield %> + <%= link_to "Reminder", home_reminder_email_test_path, class: 'btn btn-warning btn-md' %> <% if session[:logged_in] %> <%= link_to "Logout", home_test_log_out_path, class: 'btn btn-warning btn-md' %> <% else %> diff --git a/config/routes.rb b/config/routes.rb index 42f63023475ea5d3eae0dab1c0a5acb103bad498..bf204c3f415668fe657f7961a53811668bcec832 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,5 +16,6 @@ Rails.application.routes.draw do post 'sign_up/send', to: 'registrations#sign_up' get 'login', to: 'sessions#new' post 'login/send', to: 'sessions#login' + get 'home/reminder_email_test', to: 'home#reminder_email_test' end diff --git a/docker-compose.yaml b/docker-compose.yaml index 23832719cf8119d50e66b528dc04db5fa93ba780..7a1c188e92dcb8e0aacf1d88e58e16e648e91c3c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,8 +3,6 @@ version: "3.7" services: db_primary: image: mysql:5.7 - # volumes: - # - db_data:/var/lib/mysql restart: always environment: MYSQL_DATABASE: docker_dev @@ -46,3 +44,7 @@ services: - db_auth links: - db_auth + mailer: + image: driftydirt/group24mailer:0.0.3 + ports: + - "3002:3000"