diff --git a/app/controllers/threadreplies_controller.rb b/app/controllers/threadreplies_controller.rb index 298dd75..5257980 100644 --- a/app/controllers/threadreplies_controller.rb +++ b/app/controllers/threadreplies_controller.rb @@ -17,7 +17,6 @@ class ThreadrepliesController < ApplicationController @reply.forumthread = thread if @reply.save @reply.send_new_reply_mail - @reply.send_new_mention_mail position = thread.replies.count - 1 page = position / Kaminari.config.default_per_page + 1 redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}", notice: 'Reply created!' @@ -36,7 +35,7 @@ class ThreadrepliesController < ApplicationController if mod? || @reply.author.is?(current_user) old_content = @reply.content_was if @reply.update_attributes(reply_params) - @reply.send_new_mention_mail(old_content) + @reply.send_new_reply_mail(old_content) flash[:notice] = "Reply updated!" position = @reply.thread.replies.count - 1 page = position / Kaminari.config.default_per_page + 1 diff --git a/app/mailers/redstoner_mailer.rb b/app/mailers/redstoner_mailer.rb index 553dd6a..38e9956 100644 --- a/app/mailers/redstoner_mailer.rb +++ b/app/mailers/redstoner_mailer.rb @@ -28,12 +28,6 @@ class RedstonerMailer < ActionMailer::Base mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner") end - def new_thread_reply_mention_mail(user, reply) - @user = user - @reply = reply - mail(to: @user.email, subject: "#{reply.author.name} mentioned you in '#{reply.thread.title}' on Redstoner") - end - def new_post_mention_mail(user, post) @user = user @post = post diff --git a/app/models/comment.rb b/app/models/comment.rb index 6f6439b..35a9a60 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -32,8 +32,6 @@ class Comment < ActiveRecord::Base def send_new_comment_mail(old_content = "") userids = mentions(content) - mentions(old_content) - puts "userids: #{userids}" - # post + comments comments = blogpost.comments.to_a comments << blogpost if blogpost.author.mail_own_blogpost_comment? diff --git a/app/models/threadreply.rb b/app/models/threadreply.rb index b925b0e..1ca428d 100644 --- a/app/models/threadreply.rb +++ b/app/models/threadreply.rb @@ -33,32 +33,19 @@ class Threadreply < ActiveRecord::Base !!user_editor_id end - def send_new_mention_mail(old_content = "") - new_mentions = mentions(content) - mentions(old_content) - mails = [] - new_mentions.each do |user| - begin - mails << RedstonerMailer.new_thread_reply_mention_mail(user, self) if user.normal? && user.confirmed? && self.thread.can_read?(user) && user.mail_mention? - rescue => e - Rails.logger.error "---" - Rails.logger.error "WARNING: Failed to create new_thread_reply_mention_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}" - Rails.logger.error e.message - Rails.logger.error "---" - end - end - background_mailer(mails) - end - - def send_new_reply_mail - userids = [] + def send_new_reply_mail(old_content = "") + userids = new_mentions = mentions(content) - mentions(old_content) # thread + replies posts = thread.replies.to_a posts << thread if thread.author.mail_own_thread_reply? - posts.each do |post| - # don't send mail to the author of this reply, don't send to banned/disabled users - if post.author != author && post.author.normal? && post.author.confirmed? # && - userids << post.author.id if post.author.mail_other_thread_reply? + # only send "reply" mail when reply is new + unless old_content.present? + posts.each do |post| + # don't send mail to the author of this reply, don't send to banned/disabled users + if post.author != author && post.author.normal? && post.author.confirmed? # && + userids << post.author.id if post.author.mail_other_thread_reply? + end end end # making sure we don't send multiple mails to the same user diff --git a/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb b/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb deleted file mode 100644 index cba793b..0000000 --- a/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -
<%= link_to @reply.author.name, user_url(@reply.author), style: "text-decoration: none; color: #4096EE;" %> mentioned you in '<%= @reply.thread.title %>' on the Redstoner forums!
- -- <%# TODO: fix relative links + iframes %> - <%= render_md(@reply.content).html_safe %> -- - <% - position = @reply.thread.replies.count - 1 - page = position / Kaminari.config.default_per_page + 1 - %> - -
<%= link_to "Click here", forumthread_url(@reply.thread, page: page) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.
- -If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!
-Your Redstoner team
-Too much spam? Change <%= link_to "your notification settings", edit_notifications_user_url(@user), style: "text-decoration: none; color: #4096EE;" %>!
-You can contact us via: - <%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> | - <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %> -
-