Skip to content

Commit

Permalink
Add fake number for now to settings and change from name to it
Browse files Browse the repository at this point in the history
  • Loading branch information
DanJezeph15 committed Aug 22, 2023
1 parent 2706a28 commit 6c92037
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Settings(BaseSettings):
# Have to use a US number as the originator to send to the US
# https://support.messagebird.com/hc/en-us/articles/208747865-United-States
us_send_number = '15744445663'
tutorcruncher_number = '123456789' # TODO idk what our number is or where to find it on messagebird :(

@validator('pg_dsn')
def heroku_ready_pg_dsn(cls, v):
Expand Down
4 changes: 3 additions & 1 deletion src/worker/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def __init__(self, ctx: dict, group_id: int, company_id: int, recipient: SmsReci
self.m: SmsSendModel = m
self.tags = list(set(self.recipient.tags + self.m.tags + [str(self.m.uid)]))
self.messagebird: MessageBird = ctx['messagebird']
self.from_name = self.m.from_name if self.m.country_code != 'US' else self.settings.us_send_number
self.from_name = (
self.settings.tutorcruncher_number if self.m.country_code != 'US' else self.settings.us_send_number
)

async def run(self):
sms_data = await self._sms_prep()
Expand Down
6 changes: 4 additions & 2 deletions tests/test_sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from urllib.parse import urlencode
from uuid import uuid4

from src.main import settings


def test_send_message(cli, tmpdir, worker, loop):
data = {
Expand All @@ -26,7 +28,7 @@ def test_send_message(cli, tmpdir, worker, loop):
"to: Number(number='+447891123856', country_code='44', "
"number_formatted='+44 7891 123856', descr=None, is_mobile=True)"
) in msg_file
assert '\nfrom_name: foobar send\n' in msg_file
assert f'\nfrom_name: {settings.tutorcruncher_number}\n' in msg_file
assert '\nmessage:\nthis is a message bar\n' in msg_file
assert '\nlength: SmsLength(length=21, parts=1)\n' in msg_file

Expand Down Expand Up @@ -323,7 +325,7 @@ def test_link_shortening(cli, tmpdir, sync_db: SyncDb, worker, loop):
f = '69eb85e8-1504-40aa-94ff-75bb65fd8d75-447891123856.txt'
assert str(tmpdir.listdir()[0]).endswith(f)
msg_file = tmpdir.join(f).read()
assert '\nfrom_name: Morpheus\n' in msg_file
assert f'\nfrom_name: {settings.tutorcruncher_number}\n' in msg_file
assert '\nmessage:\nthis is a message click.example.com/l' in msg_file
token = re.search('message click.example.com/l(.+?)\n', msg_file).groups()[0]
assert len(token) == 12
Expand Down

0 comments on commit 6c92037

Please sign in to comment.