about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-22 17:32:51 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-22 17:32:51 +0100
commit45c7ee39b3d45159de382e8596110af04ee1ed8c (patch)
tree161516b55c190c41c1c2421e0d885960957744f2 /app/models
parent95db6cbe28acc193ff0c898790a6740c4ff3d473 (diff)
Remove unneeded indices, improve error handling in background workers, don't needlessly reload reblogged status, send Devise e-mails asynchronously
Diffstat (limited to 'app/models')
-rw-r--r--app/models/notification.rb2
-rw-r--r--app/models/user.rb4
2 files changed, 6 insertions, 0 deletions
diff --git a/app/models/notification.rb b/app/models/notification.rb
index 419f31230..c0537397c 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -11,6 +11,8 @@ class Notification < ApplicationRecord
   belongs_to :follow,    foreign_type: 'Follow',    foreign_key: 'activity_id'
   belongs_to :favourite, foreign_type: 'Favourite', foreign_key: 'activity_id'
 
+  validates :account_id, uniqueness: { scope: [:activity_type, :activity_id] }
+
   STATUS_INCLUDES = [:account, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :media_attachments, :tags, mentions: :account]].freeze
 
   scope :with_includes, -> { includes(status: STATUS_INCLUDES, mention: [status: STATUS_INCLUDES], favourite: [:account, status: STATUS_INCLUDES], follow: :account) }
diff --git a/app/models/user.rb b/app/models/user.rb
index 4eb1d20a5..7e3547dff 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -16,4 +16,8 @@ class User < ApplicationRecord
   has_settings do |s|
     s.key :notification_emails, defaults: { follow: true, reblog: true, favourite: true, mention: true }
   end
+
+  def send_devise_notification(notification, *args)
+    devise_mailer.send(notification, self, *args).deliver_later
+  end
 end