diff --git a/app/jobs/fs/download_sent_message_job.rb b/app/jobs/fs/download_sent_message_job.rb index 2f5d3356..a501fb65 100644 --- a/app/jobs/fs/download_sent_message_job.rb +++ b/app/jobs/fs/download_sent_message_job.rb @@ -4,7 +4,7 @@ def perform(fs_message_id, box:, fs_client: FsEnvironment.fs_client) raise unless box.is_a?(Fs::Box) return unless box.syncable? - return if box.messages.except_drafts.where("metadata ->> 'fs_message_id' = ?", fs_message_id).any? + return if box.messages.not_drafts.where("metadata ->> 'fs_message_id' = ?", fs_message_id).any? ActiveRecord::Base.transaction do fs_api = fs_client.api(api_connection: box.api_connection, box: box) diff --git a/app/jobs/fs/sync_box_job.rb b/app/jobs/fs/sync_box_job.rb index 9cc359c8..1e135005 100644 --- a/app/jobs/fs/sync_box_job.rb +++ b/app/jobs/fs/sync_box_job.rb @@ -4,7 +4,7 @@ def perform(box, from: Date.today - 1.week, to: Date.tomorrow) raise unless box.is_a?(Fs::Box) return unless box.syncable? - box.messages.outbox.except_drafts.find_each do |outbox_message| + box.messages.outbox.not_drafts.find_each do |outbox_message| DownloadSentMessageRelatedMessagesJob.perform_later(outbox_message, from: from, to: to) end end diff --git a/app/jobs/govbox/process_message_job.rb b/app/jobs/govbox/process_message_job.rb index d323077c..ea358d11 100644 --- a/app/jobs/govbox/process_message_job.rb +++ b/app/jobs/govbox/process_message_job.rb @@ -7,7 +7,7 @@ class ProcessMessageJob < ApplicationJob retry_on ::ApplicationRecord::FailedToAcquireLockError, wait: :polynomially_longer, attempts: Float::INFINITY def perform(govbox_message) - processed_message = ::Message.except_drafts.where(uuid: govbox_message.message_id).joins(:thread).where(thread: { box_id: govbox_message.box.id }).take + processed_message = ::Message.not_drafts.where(uuid: govbox_message.message_id).joins(:thread).where(thread: { box_id: govbox_message.box.id }).take ActiveRecord::Base.transaction do message = Govbox::Message.create_message_with_thread!(govbox_message) diff --git a/app/models/message.rb b/app/models/message.rb index 598650a9..bcd87f61 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -40,9 +40,9 @@ class Message < ApplicationRecord delegate :tenant, to: :thread delegate :box, to: :thread - scope :except_drafts, -> { where(type: [nil, 'Message']) } + scope :not_drafts, -> { where(type: [nil, 'Message']) } scope :outbox, -> { where(outbox: true) } - scope :inbox, -> { except_drafts.where.not(outbox: true) } + scope :inbox, -> { not_drafts.where.not(outbox: true) } after_update_commit ->(message) { EventBus.publish(:message_changed, message) } after_destroy_commit ->(message) { EventBus.publish(:message_destroyed, message) }