Skip to content

Commit

Permalink
Merge pull request #1794 from tactilenews/1793_fix_argument_error_sen…
Browse files Browse the repository at this point in the history
…d_unknown_content_message_signal_adapter

Fix ArgumentError by passing in id of contributor
  • Loading branch information
mattwr18 authored Feb 27, 2024
2 parents 55bc4fb + 1713a9f commit 2a76e10
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/adapters/signal_adapter/outbound.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def send!(message)
def send_unknown_content_message!(contributor)
return unless contributor_can_receive_messages?(contributor)

SignalAdapter::Outbound::Text.perform_later(contributor_id: contributor, text: Setting.signal_unknown_content_message)
SignalAdapter::Outbound::Text.perform_later(contributor_id: contributor.id, text: Setting.signal_unknown_content_message)
end

def send_welcome_message!(contributor)
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/signal_adapter/outbound/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Text < ApplicationJob
attr_reader :recipient, :text

def perform(contributor_id:, text:)
@recipient = Contributor.find(contributor_id)
@recipient = Contributor.find_by(id: contributor_id)
return unless @recipient

@text = text
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/telegram_adapter/outbound/photo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Photo < ApplicationJob
attr_reader :telegram_id, :message

def perform(contributor_id:, media:, message:)
contributor = Contributor.find(contributor_id)
contributor = Contributor.find_by(id: contributor_id)
return unless contributor

@telegram_id = contributor.telegram_id
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/telegram_adapter/outbound/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Text < ApplicationJob
end

def perform(contributor_id:, text:, message: nil)
contributor = Contributor.find(contributor_id)
contributor = Contributor.find_by(id: contributor_id)
return unless contributor

@message = message
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/threema_adapter/outbound/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.threema_instance
end

def perform(contributor_id:, file_path:, file_name: nil, caption: nil, render_type: nil)
recipient = Contributor.find(contributor_id)
recipient = Contributor.find_by(id: contributor_id)
return unless recipient

self.class.threema_instance.send(type: :file,
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/whats_app_adapter/outbound/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.twilio_instance
end

def perform(contributor_id:, message:)
contributor = Contributor.find(contributor_id)
contributor = Contributor.find_by(id: contributor_id)
return unless contributor

responses = message.files.each_with_index.map do |file, index|
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/whats_app_adapter/outbound/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.twilio_instance
end

def perform(contributor_id:, text:, message: nil)
contributor = Contributor.find(contributor_id)
contributor = Contributor.find_by(id: contributor_id)
return unless contributor

response = self.class.twilio_instance.messages.create(
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/resubscribe_contributor_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ResubscribeContributorJob < ApplicationJob
class ResubscribeError < StandardError; end

def perform(contributor_id, adapter)
contributor = Contributor.find(contributor_id)
contributor = Contributor.find_by(id: contributor_id)
return unless contributor

if contributor.deactivated_by_user.present? || contributor.deactivated_by_admin?
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/unsubscribe_contributor_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class UnsubscribeContributorJob < ApplicationJob
queue_as :unsubscribe_contributor

def perform(contributor_id, adapter)
contributor = Contributor.find(contributor_id)
contributor = Contributor.find_by(id: contributor_id)
return unless contributor
return if contributor.unsubscribed_at.present?

Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/signal_adapter/receive_polling_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

it 'bounces a warning to the contributor' do
should have_enqueued_job(SignalAdapter::Outbound::Text).with(
contributor_id: contributor,
contributor_id: contributor.id,
text: 'We cannot process this content'
)
end
Expand Down

0 comments on commit 2a76e10

Please sign in to comment.