Add ActionMailer to inform admins about new screenshots
This version only informs Christoph as a test
This commit is contained in:
parent
ae597a6235
commit
1f9187e35c
9 changed files with 55 additions and 1 deletions
|
|
@ -123,6 +123,11 @@ class PackagesController < ApplicationController
|
|||
# if @invalid_images…
|
||||
# ' #{image.image_file_name} (#{image.errors[:image].join(' and ')})
|
||||
|
||||
# Inform the admins about the upload
|
||||
if @valid_images.any?
|
||||
AdminMailer.with(package: @package).new_uploads_email.deliver_now
|
||||
end
|
||||
|
||||
# Rails does not allow dots in the URL. So we cannot use the 'respond_to'
|
||||
# and 'format' ways to handle parameters. Instead the 'returns' parameters
|
||||
# is set in routes.rb to signal that this method was called by AJAX.
|
||||
|
|
|
|||
9
app/mailers/admin_mailer.rb
Normal file
9
app/mailers/admin_mailer.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class AdminMailer < ApplicationMailer
|
||||
default from: 'notifications@mentors.debian.net'
|
||||
|
||||
def new_uploads_email
|
||||
@package = params[:package]
|
||||
#@url = 'http://example.com/login'
|
||||
mail(to: 'email@christoph-haas.de', subject: 'Please moderate new screenshot uploads')
|
||||
end
|
||||
end
|
||||
5
app/mailers/application_mailer.rb
Normal file
5
app/mailers/application_mailer.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'from@example.com'
|
||||
layout 'mailer'
|
||||
end
|
||||
|
||||
7
app/views/admin_mailer/new_uploads_email.text.erb
Normal file
7
app/views/admin_mailer/new_uploads_email.text.erb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
test
|
||||
|
||||
package is <%= @package.name %>
|
||||
|
||||
link would be <%= url_for @package %>
|
||||
|
||||
goodbye
|
||||
1
app/views/layouts/mailer.text.slim
Normal file
1
app/views/layouts/mailer.text.slim
Normal file
|
|
@ -0,0 +1 @@
|
|||
= yield
|
||||
|
|
@ -32,7 +32,16 @@ Rails.application.configure do
|
|||
config.active_storage.service = :local
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.smtp_settings = {
|
||||
address: 'localhost',
|
||||
port: 25,
|
||||
enable_starttls_auto: false
|
||||
}
|
||||
config.action_mailer.default_url_options = {
|
||||
host: "screenshots.debian.net",
|
||||
protocol: 'https'
|
||||
}
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,16 @@ Rails.application.configure do
|
|||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
config.action_mailer.smtp_settings = {
|
||||
address: 'localhost',
|
||||
port: 25,
|
||||
enable_starttls_auto: false
|
||||
}
|
||||
config.action_mailer.default_url_options = {
|
||||
host: "screenshots.debian.net",
|
||||
protocol: 'https'
|
||||
}
|
||||
|
||||
# Ignore bad email addresses and do not raise email delivery errors.
|
||||
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
|
|
|||
4
test/fixtures/action_text/rich_texts.yml
vendored
Normal file
4
test/fixtures/action_text/rich_texts.yml
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# one:
|
||||
# record: name_of_fixture (ClassOfFixture)
|
||||
# name: content
|
||||
# body: <p>In a <i>million</i> stars!</p>
|
||||
4
test/mailers/previews/admin_mailer_preview.rb
Normal file
4
test/mailers/previews/admin_mailer_preview.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/admin_mailer
|
||||
class AdminMailerPreview < ActionMailer::Preview
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue