Made notification emails get encrypted for accounts with a public key.
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -16,6 +16,7 @@ gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails'
|
||||
gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination
|
||||
gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions
|
||||
gem 'actionpack-action_caching', github: 'antulik/actionpack-action_caching', ref: '8c6e52c69315d67437f480da5dce4b7c8737fb32'
|
||||
gem 'mail-gpg'
|
||||
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
|
||||
@@ -19,29 +19,49 @@ class RedstonerMailer < ActionMailer::Base
|
||||
def new_thread_mention_mail(user, thread)
|
||||
@user = user
|
||||
@thread = thread
|
||||
mail(to: @user.email, subject: "#{thread.author.name} mentioned you in '#{thread.title}' on Redstoner")
|
||||
if @user.public_key?
|
||||
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
|
||||
else
|
||||
mail(to: @user.email, subject: "#{thread.author.name} mentioned you in '#{thread.title}' on Redstoner")
|
||||
end
|
||||
end
|
||||
|
||||
def new_thread_reply_mail(user, reply)
|
||||
@user = user
|
||||
@reply = reply
|
||||
mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner")
|
||||
if @user.public_key?
|
||||
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
|
||||
else
|
||||
mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner")
|
||||
end
|
||||
end
|
||||
|
||||
def new_post_mention_mail(user, post)
|
||||
@user = user
|
||||
@post = post
|
||||
mail(to: @user.email, subject: "#{post.author.name} mentioned you in '#{post.title}' on Redstoner")
|
||||
if @user.public_key?
|
||||
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
|
||||
else
|
||||
mail(to: @user.email, subject: "#{post.author.name} mentioned you in '#{post.title}' on Redstoner")
|
||||
end
|
||||
end
|
||||
|
||||
def new_post_comment_mail(user, comment)
|
||||
@user = user
|
||||
@comment = comment
|
||||
mail(to: @user.email, subject: "#{comment.author.name} replied to '#{comment.blogpost.title}' on Redstoner")
|
||||
if @user.public_key?
|
||||
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
|
||||
else
|
||||
mail(to: @user.email, subject: "#{comment.author.name} replied to '#{comment.blogpost.title}' on Redstoner")
|
||||
end
|
||||
end
|
||||
|
||||
def email_change_confirm_mail(user)
|
||||
@user = user
|
||||
mail(to: @user.email, subject: "Email change on Redstoner.com")
|
||||
if @user.public_key?
|
||||
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
|
||||
else
|
||||
mail(to: @user.email, subject: "Email change on Redstoner.com")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user