Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix phone call & SMS relay #2345

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix relay_oss_call and relay_oss_sms
vstpme committed Jun 26, 2023

Verified

This commit was signed with the committer’s verified signature.
rezkiy37 Michael (Mykhailo) Kravchenko
commit 4a421fe14312123b5b00556e08aa6b828245b486
4 changes: 2 additions & 2 deletions engine/apps/phone_notifications/phone_backend.py
Original file line number Diff line number Diff line change
@@ -268,7 +268,7 @@ def relay_oss_call(self, user, message):
# additional cleaning, since message come from api call and wasn't cleaned by our renderer
message = clean_markup(message).replace('"', "")

self.phone_provider.make_call(message, user.verified_phone_number)
self.phone_provider.make_call(user.verified_phone_number, message)
# create PhoneCallRecord to track limits for calls from oss instances
PhoneCallRecord.objects.create(
receiver=user,
@@ -298,7 +298,7 @@ def relay_oss_sms(self, user, message):
elif sms_left < 3:
message = self._add_sms_limit_warning(sms_left, message)

self.phone_provider.send_sms(message, user.verified_phone_number)
self.phone_provider.send_sms(user.verified_phone_number, message)
SMSRecord.objects.create(
receiver=user,
exceeded_limit=False,
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ def test_relay_oss_call(
_, user = make_organization_and_user()
phone_backend = PhoneBackend()
phone_backend.relay_oss_call(user, "relayed_call")
assert mock_make_call.called
mock_make_call.assert_called_once_with(user.verified_phone_number, "relayed_call")


@pytest.mark.django_db
@@ -66,7 +66,7 @@ def test_relay_oss_call_limit_exceed(
@pytest.mark.django_db
@mock.patch("apps.phone_notifications.phone_backend.PhoneBackend._validate_user_number", return_value=True)
@mock.patch("apps.phone_notifications.phone_backend.PhoneBackend._validate_sms_left", return_value=10)
@mock.patch("apps.phone_notifications.tests.mock_phone_provider.MockPhoneProvider.make_call")
@mock.patch("apps.phone_notifications.tests.mock_phone_provider.MockPhoneProvider.send_sms")
def test_relay_oss_sms(
mock_send_sms,
mock_validate_user_number,
@@ -75,8 +75,8 @@ def test_relay_oss_sms(
):
_, user = make_organization_and_user()
phone_backend = PhoneBackend()
phone_backend.relay_oss_call(user, "relayed_call")
assert mock_send_sms.called
phone_backend.relay_oss_sms(user, "relayed_sms")
mock_send_sms.assert_called_once_with(user.verified_phone_number, "relayed_sms")


@pytest.mark.django_db