diff --git a/app/adapters/signal_adapter/api.rb b/app/adapters/signal_adapter/api.rb
index bd33c44ab..fe4c7ea0c 100644
--- a/app/adapters/signal_adapter/api.rb
+++ b/app/adapters/signal_adapter/api.rb
@@ -13,7 +13,7 @@ def perform_request(request, contributor)
yield response if block_given?
else
error_message = JSON.parse(response.body)['error']
- mark_contributor_as_inactive(contributor) if error_message.match?(/User is not registered/)
+ mark_contributor_as_inactive(contributor) if error_message.match?(/Unregistered user/)
exception = SignalAdapter::BadRequestError.new(error_code: response.code, message: error_message)
context = {
code: response.code,
diff --git a/app/adapters/signal_adapter/outbound/file.rb b/app/adapters/signal_adapter/outbound/file.rb
index 7a3aab899..1313719ea 100644
--- a/app/adapters/signal_adapter/outbound/file.rb
+++ b/app/adapters/signal_adapter/outbound/file.rb
@@ -15,7 +15,7 @@ def perform(message:)
'Content-Type': 'application/json'
})
request.body = data.to_json
- SignalAdapter::Api.perform_request(request, recipient) do
+ SignalAdapter::Api.perform_request(request, message.recipient) do
# TODO: Do something on success. For example, mark the message as delivered?
# Or should we use deliver receipts as the source of truth.
Rails.logger.debug 'Great!'
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 1407b5fdc..42c6cc7a6 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -196,7 +196,9 @@ de:
action: Mitglied reaktivieren
automatically_marked_inactive:
text: "%{name} ist ein inaktives Mitglied deiner Community und erhält aktuell keine Recherchefragen über %{project_name}."
- possible_reason_whats_app: "Die Rufnummer wurde möglicherweise nicht bei WhatsApp registriert. Bitte überprüfe dies mit %{first_name}."
+ possible_reason_whats_app: |
+ Die Rufnummer wurde möglicherweise nicht bei WhatsApp registriert oder der Empfänger hat möglicherweise die neuen Nutzungsbedingungen und Datenschutzrichtlinien von WhatsApp nicht akzeptiert.
+ Es ist auch möglich, dass der Empfänger verwendet eine alte, nicht unterstützte Version des WhatsApp-Clients für sein Telefon. Bitte überprüfe dies mit %{first_name}.
possible_reason_signal: "Die Rufnummer wurde möglicherweise nicht bei Signal registriert. Bitte überprüfe dies mit %{first_name}."
possible_reason_threema: "Diese Threema-ID wurde möglicherweise von Threema als ungültig gemeldet. Bitte %{first_name}, die Threema-ID zu überprüfen."
possible_reason_email: "Diese E-Mail-Adresse wurde vom Server als inaktiv gemeldet. Das bedeutet, es können keine E-Mails an diese Adresse zugestellt werden."
diff --git a/spec/adapters/signal_adapter/api_spec.rb b/spec/adapters/signal_adapter/api_spec.rb
index ec5672d97..b092b7094 100644
--- a/spec/adapters/signal_adapter/api_spec.rb
+++ b/spec/adapters/signal_adapter/api_spec.rb
@@ -42,12 +42,12 @@
it { should have_received(:report) }
end
- describe 'User is not registered error' do
+ describe 'Unregistered user error' do
let!(:admin) { create_list(:user, 2, admin: true) }
let!(:non_admin_user) { create(:user) }
before do
- stub_request(:post, uri).to_return(status: 400, body: { error: 'User is not registered' }.to_json)
+ stub_request(:post, uri).to_return(status: 400, body: { error: 'Unregistered user' }.to_json)
end
subject { -> { api.perform_request(request, recipient) } }
diff --git a/spec/adapters/signal_adapter/outbound/file_spec.rb b/spec/adapters/signal_adapter/outbound/file_spec.rb
index 30a829064..cbafd076d 100644
--- a/spec/adapters/signal_adapter/outbound/file_spec.rb
+++ b/spec/adapters/signal_adapter/outbound/file_spec.rb
@@ -24,7 +24,7 @@
end
describe 'on error' do
- let(:error_message) { 'User is not registered' }
+ let(:error_message) { 'Unregistered user' }
before(:each) { stub_request(:post, 'http://signal:8080/v2/send').to_return(status: 400, body: { error: error_message }.to_json) }
it 'reports the error' do
diff --git a/spec/adapters/signal_adapter/outbound/text_spec.rb b/spec/adapters/signal_adapter/outbound/text_spec.rb
index 1654d2566..f33a71674 100644
--- a/spec/adapters/signal_adapter/outbound/text_spec.rb
+++ b/spec/adapters/signal_adapter/outbound/text_spec.rb
@@ -24,7 +24,7 @@
end
describe 'on error' do
- let(:error_message) { 'User is not registered' }
+ let(:error_message) { 'Unregistered user' }
before(:each) { stub_request(:post, 'http://signal:8080/v2/send').to_return(status: 400, body: { error: error_message }.to_json) }
it 'reports the error' do
diff --git a/spec/components/contributor_status_toggle_spec.rb b/spec/components/contributor_status_toggle_spec.rb
index 8796cbaeb..056f6ed0a 100644
--- a/spec/components/contributor_status_toggle_spec.rb
+++ b/spec/components/contributor_status_toggle_spec.rb
@@ -35,10 +35,10 @@
end
context 'through WhatsApp who requested to unsubscribe' do
- before { contributor.update(whats_app_phone_number: '+49151234567', email: nil) }
+ before { contributor.update(whats_app_phone_number: '+49151234567', email: nil, unsubscribed_at: 1.minute.ago) }
it { should have_css('strong', text: contributor.first_name) }
- it { should have_content('hat darum gebeten, vom Empfang von Nachrichten über WhatsApp abgemeldet zu werden.') }
+ it { should have_content('hat darum gebeten, vom Erhalt von Nachrichten über WhatsApp abgemeldet zu werden.') }
end
end
end
diff --git a/spec/models/contributor_spec.rb b/spec/models/contributor_spec.rb
index bcb841e42..328f4f929 100644
--- a/spec/models/contributor_spec.rb
+++ b/spec/models/contributor_spec.rb
@@ -613,10 +613,9 @@
subject { Contributor.active }
context 'given some inactive and active contributors' do
- let(:active_contributor) { create(:contributor, active: true) }
- let(:inactive_contributor) { create(:contributor, active: false) }
-
- before { active_contributor && inactive_contributor }
+ let!(:active_contributor) { create(:contributor, deactivated_at: nil) }
+ let!(:unsubscribed_contributor) { create(:contributor, unsubscribed_at: 1.day.ago) }
+ let!(:inactive_contributor) { create(:contributor, deactivated_at: 1.hour.ago) }
it 'returns only active contributors' do
should eq([active_contributor])
@@ -628,10 +627,9 @@
subject { Contributor.inactive }
context 'given some inactive and active contributors' do
- let(:active_contributor) { create(:contributor, active: true) }
- let(:inactive_contributor) { create(:contributor, active: false) }
-
- before { active_contributor && inactive_contributor }
+ let!(:active_contributor) { create(:contributor, deactivated_at: nil) }
+ let!(:unsubscribed_contributor) { create(:contributor, unsubscribed_at: 1.day.ago) }
+ let!(:inactive_contributor) { create(:contributor, deactivated_at: 1.hour.ago) }
it 'returns only inactive contributors' do
should eq([inactive_contributor])
@@ -639,6 +637,20 @@
end
end
+ describe 'scope ::unsubscribed' do
+ subject { Contributor.unsubscribed }
+
+ context 'given some inactive and active contributors' do
+ let!(:active_contributor) { create(:contributor, deactivated_at: nil) }
+ let!(:unsubscribed_contributor) { create(:contributor, unsubscribed_at: 1.day.ago) }
+ let!(:inactive_contributor) { create(:contributor, deactivated_at: 1.hour.ago) }
+
+ it 'returns only inactive contributors' do
+ should eq([unsubscribed_contributor])
+ end
+ end
+ end
+
describe '.active' do
subject { contributor.active }
it { should be(true) }
diff --git a/spec/requests/whats_app/three_sixty_dialog_webhook_spec.rb b/spec/requests/whats_app/three_sixty_dialog_webhook_spec.rb
index 1a016b0f6..b0c1b62d2 100644
--- a/spec/requests/whats_app/three_sixty_dialog_webhook_spec.rb
+++ b/spec/requests/whats_app/three_sixty_dialog_webhook_spec.rb
@@ -173,7 +173,7 @@
end
it 'marks contributor as inactive' do
- expect { subject.call }.to change { contributor.reload.deactivated_at }.from(nil).to(kind_of(ActiveSupport::TimeWithZone))
+ expect { subject.call }.to change { contributor.reload.unsubscribed_at }.from(nil).to(kind_of(ActiveSupport::TimeWithZone))
end
it 'enqueues a job to inform the contributor of successful unsubscribe' do
@@ -210,7 +210,7 @@
let!(:non_admin_user) { create(:user) }
before do
- contributor.update(deactivated_at: Time.current)
+ contributor.update(unsubscribed_at: Time.current)
params[:messages].first[:text][:body] = 'Bestellen'
end
@@ -219,7 +219,7 @@
end
it 'marks contributor as active' do
- expect { subject.call }.to change { contributor.reload.deactivated_at }.from(kind_of(ActiveSupport::TimeWithZone)).to(nil)
+ expect { subject.call }.to change { contributor.reload.unsubscribed_at }.from(kind_of(ActiveSupport::TimeWithZone)).to(nil)
end
it 'marks that contributor has responded to template message' do
diff --git a/spec/requests/whats_app/webhook_spec.rb b/spec/requests/whats_app/webhook_spec.rb
index b9c72670e..9f86d6af9 100644
--- a/spec/requests/whats_app/webhook_spec.rb
+++ b/spec/requests/whats_app/webhook_spec.rb
@@ -178,8 +178,8 @@
"_#{I18n.t('adapter.whats_app.subscribe.instructions')}_"].join("\n\n") }
end
- it 'marks contributor as inactive' do
- expect { subject.call }.to change { contributor.reload.deactivated_at }.from(nil).to(kind_of(ActiveSupport::TimeWithZone))
+ it 'marks contributor as unsubscribed' do
+ expect { subject.call }.to change { contributor.reload.unsubscribed_at }.from(nil).to(kind_of(ActiveSupport::TimeWithZone))
end
it 'enqueues a job to inform the contributor of successful unsubscribe' do
@@ -212,7 +212,7 @@
let!(:non_admin_user) { create(:user) }
before do
- contributor.update(deactivated_at: Time.current)
+ contributor.update(unsubscribed_at: Time.current)
params['Body'] = 'Bestellen'
end
@@ -221,7 +221,7 @@
end
it 'marks contributor as active' do
- expect { subject.call }.to change { contributor.reload.deactivated_at }.from(kind_of(ActiveSupport::TimeWithZone)).to(nil)
+ expect { subject.call }.to change { contributor.reload.unsubscribed_at }.from(kind_of(ActiveSupport::TimeWithZone)).to(nil)
end
it 'marks that contributor has responded to template message' do