about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/v1/statuses_controller.rb2
-rw-r--r--app/models/notification.rb2
-rw-r--r--app/models/user.rb4
-rw-r--r--app/services/notify_service.rb2
-rw-r--r--app/services/process_feed_service.rb2
-rw-r--r--app/workers/salmon_worker.rb2
6 files changed, 12 insertions, 2 deletions
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb
index 53578b2f7..604e2969d 100644
--- a/app/controllers/api/v1/statuses_controller.rb
+++ b/app/controllers/api/v1/statuses_controller.rb
@@ -54,7 +54,7 @@ class Api::V1::StatusesController < ApiController
   end
 
   def reblog
-    @status = ReblogService.new.call(current_user.account, Status.find(params[:id])).reload
+    @status = ReblogService.new.call(current_user.account, Status.find(params[:id]))
     render action: :show
   end
 
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
diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb
index c0f1d4c53..772adfb90 100644
--- a/app/services/notify_service.rb
+++ b/app/services/notify_service.rb
@@ -10,6 +10,8 @@ class NotifyService < BaseService
 
     create_notification
     send_email if email_enabled?
+  rescue ActiveRecord::RecordInvalid
+    return
   end
 
   private
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index 8daafd444..1cd801b80 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -61,7 +61,7 @@ class ProcessFeedService < BaseService
 
       status.save!
 
-      NotifyService.new.call(status.reblog.account, status) if status.reblog?
+      NotifyService.new.call(status.reblog.account, status) if status.reblog? && status.reblog.account.local?
       Rails.logger.debug "Queuing remote status #{status.id} (#{id}) for distribution"
       DistributionWorker.perform_async(status.id)
       status
diff --git a/app/workers/salmon_worker.rb b/app/workers/salmon_worker.rb
index 12b46e92f..24fb94012 100644
--- a/app/workers/salmon_worker.rb
+++ b/app/workers/salmon_worker.rb
@@ -5,5 +5,7 @@ class SalmonWorker
 
   def perform(account_id, body)
     ProcessInteractionService.new.call(body, Account.find(account_id))
+  rescue ActiveRecord::RecordNotFound
+    true
   end
 end