Added:
trunk/app/models/notifier.rb
trunk/app/views/notifier/
trunk/app/views/notifier/received_picture.rhtml
trunk/test/fixtures/notifier/
trunk/test/unit/notifier_test.rb
Modified:
trunk/app/models/photo_receiver.rb
trunk/config/environment.rb
Log:
Sends email upon receiving a picture.
Added: trunk/app/models/notifier.rb
==============================================================================
--- (empty file)
+++ trunk/app/models/notifier.rb Fri Dec 7 21:31:45 2007
@@ -0,0 +1,9 @@
+class Notifier < ActionMailer::Base
+
+ def received_picture(email)
+ recipients email
+ from "photo...@gmail.com"
+ subject "Your picture has been received!"
+ end
+
+end
Modified: trunk/app/models/photo_receiver.rb
==============================================================================
--- trunk/app/models/photo_receiver.rb (original)
+++ trunk/app/models/photo_receiver.rb Fri Dec 7 21:31:45 2007
@@ -16,6 +16,7 @@
:date => Date.today,
:score => 0
)
+ break
elsif part.content_type =~ /text\/html/
# Check for Sprint Picture Mail.
@@ -32,6 +33,8 @@
:score => 0
)
end
+
+ break
end
end
@@ -39,6 +42,7 @@
if @picture.save
# Create reply email.
+ Notifier.deliver_received_picture(email.from[0])
else
raise "Could not save picture."
end
Added: trunk/app/views/notifier/received_picture.rhtml
==============================================================================
--- (empty file)
+++ trunk/app/views/notifier/received_picture.rhtml Fri Dec 7 21:31:45 2007
@@ -0,0 +1 @@
+Your picture has been successfully submitted and is pending approval.
\ No newline at end of file
Modified: trunk/config/environment.rb
==============================================================================
--- trunk/config/environment.rb (original)
+++ trunk/config/environment.rb Fri Dec 7 21:31:45 2007
@@ -14,7 +14,7 @@
# Settings in config/environments/* take precedence over those
specified here
# Skip frameworks you're not going to use (only works if using vendor/rails)
- # config.frameworks -= [ :action_web_service, :action_mailer ]
+ # config.frameworks -= [ :action_web_service ]
# Only load the plugins named here, by default all plugins in
vendor/plugins are loaded
# config.plugins = %W( exception_notification ssl_requirement )
@@ -57,4 +57,15 @@
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register "application/x-mobile", :mobile
-# Include your application configuration below
\ No newline at end of file
+# Include your application configuration below
+require 'tlsmail'
+Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
+
+ActionMailer::Base.server_settings = {
+ :address => 'smtp.gmail.com',
+ :port => 587,
+ :domain => 'photohunt.org',
+ :authentication => :plain,
+ :user_name => 'photo...@gmail.com',
+ :password => 'password'
+}
\ No newline at end of file
Added: trunk/test/unit/notifier_test.rb
==============================================================================
--- (empty file)
+++ trunk/test/unit/notifier_test.rb Fri Dec 7 21:31:45 2007
@@ -0,0 +1,27 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class NotifierTest < Test::Unit::TestCase
+ FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
+ CHARSET = "utf-8"
+
+ include ActionMailer::Quoting
+
+ def setup
+ ActionMailer::Base.delivery_method = :test
+ ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.deliveries = []
+
+ @expected = TMail::Mail.new
+ @expected.set_content_type "text", "plain", { "charset" => CHARSET }
+ @expected.mime_version = '1.0'
+ end
+
+ private
+ def read_fixture(action)
+ IO.readlines("#{FIXTURES_PATH}/notifier/#{action}")
+ end
+
+ def encode(subject)
+ quoted_printable(subject, CHARSET)
+ end
+end