Archived
Merge pull request #44.
This commit is contained in:
@@ -352,7 +352,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def user_params(add = [])
|
||||
a = [:ign, :email, :password, :password_confirmation, :mail_own_thread_reply, :mail_other_thread_reply, :mail_own_blogpost_comment, :mail_other_blogpost_comment, :mail_mention] + add
|
||||
a = [:ign, :email, :password, :password_confirmation, :mail_own_thread_reply, :mail_other_thread_reply, :mail_own_blogpost_comment, :mail_other_blogpost_comment, :mail_mention, :public_key] + add
|
||||
params.require(:user).permit(a)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,6 +22,8 @@ class User < ActiveRecord::Base
|
||||
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[(IPv6)?[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."}
|
||||
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."}
|
||||
|
||||
validates :public_key, format: {with: /\A(-----BEGIN PGP PUBLIC KEY BLOCK-----((.|\n)*?)-----END PGP PUBLIC KEY BLOCK-----)?\z/i, message: "That doesn't look like a PGP formatted public key."}
|
||||
|
||||
has_many :blogposts
|
||||
has_many :comments
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Public Key</h1>
|
||||
<p>All notification emails will be encrypted with this key if you supply it.</p>
|
||||
<%= f.text_area :public_key, placeholder: "-----BEGIN PGP PUBLIC KEY BLOCK-----" %>
|
||||
<p><%= f.submit "Save changes", class: "btn blue left" %></p>
|
||||
<div class="clear"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user