Add flag to enable/disable mail notifications

This commit is contained in:
Leonardo Crauss Daronco 2016-12-08 18:55:41 -02:00
parent e94f3d7a10
commit f763d8394e
3 changed files with 40 additions and 32 deletions

View File

@ -171,8 +171,10 @@ class BbbController < ApplicationController
RecordingCreatedJob.perform_later(token, parse_recording_for_view(rec_info))
# send an email to the owner of this recording, if defined
owner = User.find_by(encrypted_id: token)
RecordingReadyEmailJob.perform_later(owner) if owner.present?
if Rails.configuration.mail_notifications
owner = User.find_by(encrypted_id: token)
RecordingReadyEmailJob.perform_later(owner) if owner.present?
end
# TODO: remove the webhook now that the meeting and recording are done
# remove only if the meeting is not running, otherwise the hook is needed

View File

@ -38,35 +38,38 @@ module Greenlight
config.bigbluebutton_endpoint = ENV['BIGBLUEBUTTON_ENDPOINT']
config.bigbluebutton_secret = ENV['BIGBLUEBUTTON_SECRET']
# GreenLight
config.use_webhooks = ENV['GREENLIGHT_USE_WEBHOOKS']
config.smtp_from = ENV['SMTP_FROM']
config.smtp_server = ENV['SMTP_SERVER']
config.smtp_domain = ENV['SMTP_DOMAIN']
config.smtp_port = ENV['SMTP_PORT'] || 587
config.smtp_username = ENV['SMTP_USERNAME']
config.smtp_password = ENV['SMTP_PASSWORD']
config.smtp_auth = ENV['SMTP_AUTH'] || "login"
config.smtp_starttls_auto = ENV['SMTP_STARTTLS_AUTO'].nil? ? true : ENV['SMTP_STARTTLS_AUTO']
config.smtp_tls = ENV['SMTP_TLS'].nil? ? false : ENV['SMTP_TLS']
config.use_webhooks = ENV['GREENLIGHT_USE_WEBHOOKS'] == "true"
config.mail_notifications = ENV['GREENLIGHT_MAIL_NOTIFICATIONS'] == "true"
# SMTP
config.action_mailer.default_url_options = { host: ENV['GREENLIGHT_DOMAIN'] }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:address => config.smtp_server,
:domain => config.smtp_domain,
:port => config.smtp_port,
:user_name => config.smtp_username,
:password => config.smtp_password,
:authentication => config.smtp_auth,
:enable_starttls_auto => config.smtp_starttls_auto,
:tls => config.smtp_tls
}
config.action_mailer.default_options = {
from: config.smtp_from
}
# SMTP and action mailer
if config.mail_notifications
config.smtp_from = ENV['SMTP_FROM']
config.smtp_server = ENV['SMTP_SERVER']
config.smtp_domain = ENV['SMTP_DOMAIN']
config.smtp_port = ENV['SMTP_PORT'] || 587
config.smtp_username = ENV['SMTP_USERNAME']
config.smtp_password = ENV['SMTP_PASSWORD']
config.smtp_auth = ENV['SMTP_AUTH'] || "login"
config.smtp_starttls_auto = ENV['SMTP_STARTTLS_AUTO'].nil? ? true : ENV['SMTP_STARTTLS_AUTO']
config.smtp_tls = ENV['SMTP_TLS'].nil? ? false : ENV['SMTP_TLS']
config.action_mailer.default_url_options = { host: ENV['GREENLIGHT_DOMAIN'] }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: config.smtp_server,
domain: config.smtp_domain,
port: config.smtp_port,
user_name: config.smtp_username,
password: config.smtp_password,
authentication: config.smtp_auth,
enable_starttls_auto: config.smtp_starttls_auto,
tls: config.smtp_tls
}
config.action_mailer.default_options = {
from: config.smtp_from
}
end
end
end

View File

@ -20,7 +20,10 @@ GREENLIGHT_USE_WEBHOOKS=false
# The web site domain, needed for emails mostly
GREENLIGHT_DOMAIN=localhost
# SMTP configurations
# Enable email notifications
GREENLIGHT_MAIL_NOTIFICATIONS=true
# Email configurations
SMTP_FROM=email@gmail.com
SMTP_SERVER=smtp.gmail.com
SMTP_DOMAIN=gmail.com