Skip to content

Commit

Permalink
Rename error to MissingRelatedMessagesError
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Dec 3, 2024
1 parent 9fa0780 commit 7a6db06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/jobs/fs/download_sent_message_related_messages_job.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Fs
class DownloadSentMessageRelatedMessagesJob < ApplicationJob
class NoRelatedMessagesError < StandardError
class MissingRelatedMessagesError < StandardError
end

retry_on NoRelatedMessagesError, attempts: 1 do |_job, _error|
retry_on MissingRelatedMessagesError, attempts: 1 do |_job, _error|
# no-op
end

Expand All @@ -16,7 +16,7 @@ def perform(outbox_message, from: nil, to: nil, fs_client: FsEnvironment.fs_clie
0.step do |k|
received_messages = fs_api.fetch_received_messages(sent_message_id: outbox_message.metadata['fs_message_id'], page: k + 1, count: batch_size, from: from, to: to)

raise NoRelatedMessagesError if outbox_message.thread.messages.excluding(outbox_message).none? && received_messages['messages'].none? && outbox_message.delivered_at < 1.hour.ago
raise MissingRelatedMessagesError if outbox_message.thread.messages.excluding(outbox_message).none? && received_messages['messages'].none? && outbox_message.delivered_at < 1.hour.ago

received_messages['messages'].each do |received_message|
::Fs::DownloadReceivedMessageJob.perform_later(received_message['message_id'], box: outbox_message.box)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Fs::DownloadSentMessageRelatedMessagesJobTest < ActiveJob::TestCase
**{sent_message_id: outbox_message.metadata['fs_message_id'], page: 1, count: 25, from: nil, to: nil}

FsEnvironment.fs_client.stub :api, fs_api do
assert_raise(Fs::DownloadSentMessageRelatedMessagesJob::NoRelatedMessagesError) do
assert_raise(Fs::DownloadSentMessageRelatedMessagesJob::MissingRelatedMessagesError) do
Fs::DownloadSentMessageRelatedMessagesJob.new.perform(outbox_message)
end
end
Expand Down

0 comments on commit 7a6db06

Please sign in to comment.