remove thread mention mail, use reply mail instead
This commit is contained in:
@@ -17,7 +17,6 @@ class ThreadrepliesController < ApplicationController
|
|||||||
@reply.forumthread = thread
|
@reply.forumthread = thread
|
||||||
if @reply.save
|
if @reply.save
|
||||||
@reply.send_new_reply_mail
|
@reply.send_new_reply_mail
|
||||||
@reply.send_new_mention_mail
|
|
||||||
position = thread.replies.count - 1
|
position = thread.replies.count - 1
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
page = position / Kaminari.config.default_per_page + 1
|
||||||
redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}", notice: 'Reply created!'
|
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)
|
if mod? || @reply.author.is?(current_user)
|
||||||
old_content = @reply.content_was
|
old_content = @reply.content_was
|
||||||
if @reply.update_attributes(reply_params)
|
if @reply.update_attributes(reply_params)
|
||||||
@reply.send_new_mention_mail(old_content)
|
@reply.send_new_reply_mail(old_content)
|
||||||
flash[:notice] = "Reply updated!"
|
flash[:notice] = "Reply updated!"
|
||||||
position = @reply.thread.replies.count - 1
|
position = @reply.thread.replies.count - 1
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
page = position / Kaminari.config.default_per_page + 1
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ class RedstonerMailer < ActionMailer::Base
|
|||||||
mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner")
|
mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner")
|
||||||
end
|
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)
|
def new_post_mention_mail(user, post)
|
||||||
@user = user
|
@user = user
|
||||||
@post = post
|
@post = post
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class Comment < ActiveRecord::Base
|
|||||||
def send_new_comment_mail(old_content = "")
|
def send_new_comment_mail(old_content = "")
|
||||||
userids = mentions(content) - mentions(old_content)
|
userids = mentions(content) - mentions(old_content)
|
||||||
|
|
||||||
puts "userids: #{userids}"
|
|
||||||
|
|
||||||
# post + comments
|
# post + comments
|
||||||
comments = blogpost.comments.to_a
|
comments = blogpost.comments.to_a
|
||||||
comments << blogpost if blogpost.author.mail_own_blogpost_comment?
|
comments << blogpost if blogpost.author.mail_own_blogpost_comment?
|
||||||
|
|||||||
@@ -33,32 +33,19 @@ class Threadreply < ActiveRecord::Base
|
|||||||
!!user_editor_id
|
!!user_editor_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_new_mention_mail(old_content = "")
|
def send_new_reply_mail(old_content = "")
|
||||||
new_mentions = mentions(content) - mentions(old_content)
|
userids = 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 = []
|
|
||||||
|
|
||||||
# thread + replies
|
# thread + replies
|
||||||
posts = thread.replies.to_a
|
posts = thread.replies.to_a
|
||||||
posts << thread if thread.author.mail_own_thread_reply?
|
posts << thread if thread.author.mail_own_thread_reply?
|
||||||
posts.each do |post|
|
# only send "reply" mail when reply is new
|
||||||
# don't send mail to the author of this reply, don't send to banned/disabled users
|
unless old_content.present?
|
||||||
if post.author != author && post.author.normal? && post.author.confirmed? # &&
|
posts.each do |post|
|
||||||
userids << post.author.id if post.author.mail_other_thread_reply?
|
# 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
|
||||||
end
|
end
|
||||||
# making sure we don't send multiple mails to the same user
|
# making sure we don't send multiple mails to the same user
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<div style="font-family: 'Oswald','Calibri','Arial','DejaVu Sans','Open Sans','Lucida Sans','Lucida Grande','Lucida Sans Unicode',sans-serif; background: #F2F2F2">
|
|
||||||
<div style="color: #3f3f3f; width: 600px; max-width: 100%; padding: 2em 0; margin: auto;">
|
|
||||||
Hi <%= @user.name %>!
|
|
||||||
|
|
||||||
<p><%= 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!</p>
|
|
||||||
|
|
||||||
<blockquote>
|
|
||||||
<%# TODO: fix relative links + iframes %>
|
|
||||||
<%= render_md(@reply.content).html_safe %>
|
|
||||||
</blockquote>
|
|
||||||
|
|
||||||
<%
|
|
||||||
position = @reply.thread.replies.count - 1
|
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
|
||||||
%>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<p><%= link_to "Click here", forumthread_url(@reply.thread, page: page) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.</p>
|
|
||||||
|
|
||||||
<p>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!</p>
|
|
||||||
<p>Your Redstoner team</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="background: #444; width: 100%; color: #fff; margin: auto; text-align: center; display: inline-block;">
|
|
||||||
<div style="margin: 2em;">
|
|
||||||
<p><i>Too much spam? Change <%= link_to "your notification settings", edit_notifications_user_url(@user), style: "text-decoration: none; color: #4096EE;" %>!</i></p>
|
|
||||||
</div>
|
|
||||||
<p>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;" %>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -29,12 +29,6 @@ class AllPreview < ActionMailer::Preview
|
|||||||
RedstonerMailer.new_thread_reply_mail(@@user, reply)
|
RedstonerMailer.new_thread_reply_mail(@@user, reply)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_thread_reply_mention_mail
|
|
||||||
thread = Forumthread.new(id: 123, user_author: @@op, title: "Wow, test thread!", content: "You should not see this...")
|
|
||||||
reply = Threadreply.new(id: 312, user_author: @@user, content: "# Markdown!\n\n@mention\n`incline code`\n\n<b>html?</b>\n\n[yt:abcd1234]\n\n[link](/forums)", forumthread: thread)
|
|
||||||
RedstonerMailer.new_thread_reply_mention_mail(@@user, reply)
|
|
||||||
end
|
|
||||||
|
|
||||||
def new_post_mention_mail
|
def new_post_mention_mail
|
||||||
post = Blogpost.new(id: 123, user_author: @@op, title: "Wow, test post!", content: "@mention Wow, that is **cool**!")
|
post = Blogpost.new(id: 123, user_author: @@op, title: "Wow, test post!", content: "@mention Wow, that is **cool**!")
|
||||||
RedstonerMailer.new_post_mention_mail(@@user, post)
|
RedstonerMailer.new_post_mention_mail(@@user, post)
|
||||||
|
|||||||
Reference in New Issue
Block a user