georgia_mailer 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4faad27e6208514d3e840eb69e4ff5d5044a2d4f
4
- data.tar.gz: 169e7f7f479f689915d0ceea5ecf2c38f0823182
3
+ metadata.gz: 6aafa57ea78d8babbab38651552c658541092a45
4
+ data.tar.gz: f7d0608941ff2db9476c12ec484d19358126ce19
5
5
  SHA512:
6
- metadata.gz: ec6f19b865de5c131c082a848cca03d95fc1b1a30c19dd5e0849b20c3cdbe415e7006a272fff3d422bc32ece89513e3f1e85a0955322ba9e8ed3f332d265e4b4
7
- data.tar.gz: 3826207368f8fd607caf5c8b2d6165968083143dbbcb5a64a9bf4b79f99e94e33ed4590c85448f095c0baaab5bfd79f2c1aac2797f5563506487eaa2f0da1019
6
+ metadata.gz: 0fe796c554d3f1c6e1113cc46786141f2cf58c37d56d0d7c2cd3c56d6aec271900044d91d5d64b587745eab5f22d5482ac247ce538ff46dd35b6dc3ccb5db5a5
7
+ data.tar.gz: 970f5f117b2f7c3350888beb19b78ce2979964b08156b19b62cf4d049e136ac9e58b2eb16b0ec6bb9f70cd6b51c0cea433f5a899156c7b7142bad63aa41601c0
@@ -67,8 +67,8 @@ module Georgia
67
67
  private
68
68
 
69
69
  def prepare_search
70
- @results = ::Georgia::Indexer.search(GeorgiaMailer::Message, params)
71
- @messages = GeorgiaMailer::MessageDecorator.decorate_collection(@results)
70
+ @search = ::Georgia::Indexer.search(GeorgiaMailer::Message, params)
71
+ @messages = GeorgiaMailer::MessageDecorator.decorate_collection(@search.results)
72
72
  end
73
73
 
74
74
  end
@@ -1,11 +1,11 @@
1
1
  module GeorgiaMailer
2
2
  class MessagesController < ::ApplicationController
3
3
 
4
- # Convenient method to create and check for spam
5
4
  def create
6
- @message = GeorgiaMailer::Message.new(message_params)
5
+ @message = Message.new(message_params)
7
6
  if @message.save
8
- SpamWorker.perform_async(@message.id)
7
+ EmailDeliveryWorker.new.async.later(60, @message.id)
8
+ SpamWorker.new.async.perform(@message.id)
9
9
  respond_to do |format|
10
10
  format.html { redirect_to :back, notice: 'Message delivered successfully' }
11
11
  format.js { render layout: false }
@@ -23,7 +23,7 @@ module GeorgiaMailer
23
23
  def message_params
24
24
  @message_params = {}
25
25
  params[:message].each do |key, value|
26
- @message_params[key] = value.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
26
+ @message_params[key] = value.force_encoding('UTF-8')
27
27
  end
28
28
  @message_params[:referrer] = request.referrer
29
29
  @message_params[:user_ip] = request.remote_ip
@@ -6,8 +6,8 @@ module GeorgiaMailer
6
6
  emails_to = Georgia::User.admins.map(&:email)
7
7
  unless emails_to.empty?
8
8
  mail(
9
- from: "georgia@motioneleven.com",
10
- to: "noreply@motioneleven.com",
9
+ from: "noreply@georgiacms.com",
10
+ to: "noreply@georgiacms.com",
11
11
  bcc: emails_to,
12
12
  subject: "New message from #{Georgia.title}"
13
13
  )
@@ -12,7 +12,7 @@ module GeorgiaMailer
12
12
  validates :email, format: /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
13
13
  validates :message, presence: true
14
14
 
15
- mount_uploader :attachment, Georgia::AttachmentUploader
15
+ mount_uploader :attachment, Ckeditor::AttachmentFileUploader
16
16
 
17
17
  # Anti Spam: check https://github.com/joshfrench/rakismet for more details
18
18
  include Rakismet::Model
@@ -0,0 +1,17 @@
1
+ module GeorgiaMailer
2
+ class SpamCheck
3
+
4
+ def initialize message
5
+ @message = message
6
+ end
7
+
8
+ # The .spam? method comes from Rakismet. It gathers the necessary information and
9
+ # and calls Akismet for a spam check. It returns true or false based on the status
10
+ #
11
+ # https://github.com/joshfrench/rakismet/blob/master/lib/rakismet/model.rb
12
+ def call
13
+ @message.spam?
14
+ end
15
+
16
+ end
17
+ end
@@ -25,9 +25,7 @@
25
25
  <%= message_actions_list(@message) %>
26
26
  </ul>
27
27
  </div>
28
- <strong>
29
- <%= @message.name_or_anonymous %>
30
- </strong>
28
+ <strong><%= @message.name_or_anonymous %></strong>
31
29
  <span>&lt;<%= @message.email %>&gt;</span>
32
30
  <span>on <%= @message.created_at.strftime('%F %H:%M') %></span>
33
31
  <span>sent from <%= link_to @message.referrer, @message.referrer %></span>
@@ -42,9 +40,9 @@
42
40
  <p>
43
41
  <b>Attachment</b>:
44
42
  <% if @message.attachment.try(:file) and @message.attachment.file.exists? %>
45
- <%= link_to @message.attachment.file.filename, @message.attachment.url %>
43
+ <%= link_to @message.attachment.file.filename, @message.attachment.url %>
46
44
  <% else -%>
47
- <span class='muted'>There were no attachment.</span>
45
+ <span class='muted'>There were no attachments.</span>
48
46
  <% end -%>
49
47
  </p>
50
48
  </div>
@@ -40,29 +40,14 @@ a {
40
40
  color: #FFF;
41
41
  background-color: #348eda;
42
42
  border:solid #348eda;
43
- border-width:10px 20px;
43
+ border-width: 5px 20px;
44
44
  line-height:2;
45
45
  font-weight:bold;
46
46
  margin-right:10px;
47
47
  text-align:center;
48
48
  cursor:pointer;
49
49
  display: inline-block;
50
- border-radius: 25px;
51
- }
52
-
53
- .btn-secondary {
54
- text-decoration:none;
55
- color: #FFF;
56
- background-color: #aaa;
57
- border:solid #aaa;
58
- border-width:10px 20px;
59
- line-height:2;
60
- font-weight:bold;
61
- margin-right:10px;
62
- text-align:center;
63
- cursor:pointer;
64
- display: inline-block;
65
- border-radius: 25px;
50
+ border-radius: 5px;
66
51
  }
67
52
 
68
53
  .last {
@@ -189,11 +174,10 @@ ul li, ol li {
189
174
  <td>
190
175
  <p>Hi there,</p>
191
176
  <p>You've received a new message on Georgia CMS from <%= @message.name_or_anonymous %></p>
192
- <h1><%= @message.subject %></h1>
177
+ <% if @message.subject.present? %><h1><%= @message.subject %></h1><% end %>
193
178
  <p><%= @message.message %></p>
194
- <% if @message.phone.present? %>
195
- <p><%= @message.phone %></p>
196
- <% end -%>
179
+ <% if @message.phone.present? %><p><%= @message.phone %></p><% end -%>
180
+ <p><a href="<%= georgia.message_path(@message, only_path: false) %>" class='btn-primary'>Have a closer look</a></p>
197
181
  <p>Thanks, have a lovely day.</p>
198
182
  </td>
199
183
  </tr>
@@ -0,0 +1,19 @@
1
+ module GeorgiaMailer
2
+ class EmailDeliveryWorker
3
+ include SuckerPunch::Job
4
+
5
+ def perform(message_id)
6
+ ActiveRecord::Base.connection_pool.with_connection do
7
+ message = Message.find(message_id)
8
+ unless message.spam or !GeorgiaMailer.turn_on_email_notifications
9
+ Notifier.new_message_notification(message).deliver
10
+ end
11
+ end
12
+ end
13
+
14
+ def later(sec, message_id)
15
+ after(sec) { perform(message_id) }
16
+ end
17
+
18
+ end
19
+ end
@@ -1,17 +1,16 @@
1
1
  module GeorgiaMailer
2
2
  class SpamWorker
3
- include Sidekiq::Worker
3
+ include SuckerPunch::Job
4
4
 
5
5
  def perform(message_id)
6
- begin
7
- @message = GeorgiaMailer::Message.find(message_id)
8
- is_spam = @message.spam?
9
- @message.update_attributes(spam: is_spam, verified_at: Time.zone.now)
10
- unless @message.spam or !GeorgiaMailer.turn_on_email_notifications
11
- GeorgiaMailer::Notifier.new_message_notification(@message).deliver
6
+ ActiveRecord::Base.connection_pool.with_connection do
7
+ begin
8
+ message = Message.find(message_id)
9
+ is_spam = SpamCheck.new(message).call
10
+ message.update_attributes(spam: is_spam, verified_at: Time.zone.now)
11
+ rescue ActiveRecord::RecordNotFound
12
+ Rails.logger.info "Message with ID #{message_id} was destroy before it could be processed"
12
13
  end
13
- rescue ActiveRecord::RecordNotFound
14
- Rails.logger.info "Message with ID #{message_id} was destroy before it could be processed"
15
14
  end
16
15
  end
17
16
 
@@ -34,7 +34,7 @@ module Georgia
34
34
  with(:spam, (params[:s] || 'clean'))
35
35
  order_by (params[:o] || :created_at), (params[:dir] || :desc)
36
36
  paginate(page: params[:page], per_page: (params[:per] || 25))
37
- end.results
37
+ end
38
38
  end
39
39
 
40
40
  end
@@ -36,7 +36,7 @@ module Georgia
36
36
  end
37
37
  end
38
38
  sort { by (params[:o] || :created_at), (params[:dir] || :desc) } if params[:query].blank?
39
- end.results
39
+ end
40
40
  end
41
41
 
42
42
  end
@@ -4,7 +4,7 @@ module GeorgiaMailer
4
4
 
5
5
  require 'georgia'
6
6
  require 'rakismet'
7
- require 'sidekiq'
7
+ require 'sucker_punch'
8
8
 
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module GeorgiaMailer
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: georgia_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathieu Gagné
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-06 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: georgia
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: sidekiq
42
+ name: sucker_punch
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
@@ -60,37 +60,38 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - app/assets/javascripts/georgia_mailer/components/message_table.js.coffee
64
- - app/assets/javascripts/georgia_mailer/application.js
65
- - app/assets/stylesheets/georgia_mailer/settings/_color.scss
66
- - app/assets/stylesheets/georgia_mailer/modules/_message.scss
67
- - app/assets/stylesheets/georgia_mailer/mixins/_ellipsis.scss
68
- - app/assets/stylesheets/georgia_mailer/application.css.scss
69
- - app/decorators/georgia_mailer/message_decorator.rb
70
- - app/models/georgia_mailer/message.rb
71
- - app/controllers/georgia/messages_controller.rb
72
63
  - app/controllers/georgia_mailer/messages_controller.rb
73
- - app/views/georgia/header/_messages.html.erb
74
- - app/views/georgia/messages/destroy.js.erb
75
- - app/views/georgia/messages/show.html.erb
76
- - app/views/georgia/messages/search.html.erb
77
- - app/views/georgia/georgia_mailer/messages/_message.html.erb
64
+ - app/controllers/georgia/messages_controller.rb
78
65
  - app/views/georgia_mailer/messages/create.js.erb
79
66
  - app/views/georgia_mailer/notifier/new_message_notification.html.erb
67
+ - app/views/georgia/georgia_mailer/messages/_message.html.erb
68
+ - app/views/georgia/messages/destroy.js.erb
69
+ - app/views/georgia/messages/search.html.erb
70
+ - app/views/georgia/messages/show.html.erb
71
+ - app/views/georgia/header/_messages.html.erb
72
+ - app/workers/georgia_mailer/email_delivery_worker.rb
80
73
  - app/workers/georgia_mailer/spam_worker.rb
74
+ - app/helpers/georgia/messages_helper.rb
75
+ - app/assets/stylesheets/georgia_mailer/modules/_message.scss
76
+ - app/assets/stylesheets/georgia_mailer/settings/_color.scss
77
+ - app/assets/stylesheets/georgia_mailer/mixins/_ellipsis.scss
78
+ - app/assets/stylesheets/georgia_mailer/application.css.scss
79
+ - app/assets/javascripts/georgia_mailer/application.js
80
+ - app/assets/javascripts/georgia_mailer/components/message_table.js.coffee
81
81
  - app/mailers/georgia_mailer/notifier.rb
82
+ - app/models/georgia_mailer/message.rb
83
+ - app/decorators/georgia_mailer/message_decorator.rb
82
84
  - app/presenters/georgia_mailer/message_actions_presenter.rb
83
- - app/helpers/georgia/messages_helper.rb
84
- - app/uploaders/georgia_mailer/attachment_uploader.rb
85
+ - app/services/georgia_mailer/spam_check.rb
85
86
  - config/routes.rb
86
87
  - db/migrate/001_create_georgia_mailer_messages.rb
87
- - lib/tasks/georgia_mailer_tasks.rake
88
- - lib/generators/georgia_mailer/install/install_generator.rb
88
+ - lib/georgia_mailer/version.rb
89
+ - lib/georgia_mailer/engine.rb
89
90
  - lib/georgia_mailer.rb
91
+ - lib/tasks/georgia_mailer_tasks.rake
90
92
  - lib/georgia/indexer/extensions/solr_adapter/georgia_mailer/message.rb
91
93
  - lib/georgia/indexer/extensions/tire_adapter/georgia_mailer/message.rb
92
- - lib/georgia_mailer/engine.rb
93
- - lib/georgia_mailer/version.rb
94
+ - lib/generators/georgia_mailer/install/install_generator.rb
94
95
  - MIT-LICENSE
95
96
  - Rakefile
96
97
  - README.md
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
- module GeorgiaMailer
3
- class AttachmentUploader < CarrierWave::Uploader::Base
4
-
5
- storage :fog
6
-
7
- def store_dir
8
- "/attachments/#{model.id}"
9
- end
10
-
11
- def extension_white_list
12
- ["doc", "docx", "xls", "odt", "ods", "pdf", "rar", "zip", "tar", "tar.gz"]
13
- end
14
-
15
- end
16
- end