task(recovery-phone, auth): Allow for fallback sms messages#18433
task(recovery-phone, auth): Allow for fallback sms messages#18433vpomerleau merged 1 commit intomainfrom
Conversation
| }); | ||
|
|
||
| it('Should setup a phone number', async () => { | ||
| it.only('Should setup a phone number', async () => { |
| }; | ||
| const mockGetFormattedMessage = async (code: string) => { | ||
| return { | ||
| msg: `${code} is your Mozilla verification code. Expires in 5 minutes.`, |
There was a problem hiding this comment.
Maybe I'm over thinking but I wonder if we need to include the expiration. The expiration is on the webpage. For reference Twilio sends this message, Your Twilio verification code is: 859440 and does not include expiration time. In this case, the text lenght would be rough 40 characters so the risk for translations being over 160 would be much lower.
| ? `${code} is your Mozilla verification code. Expires in 5 minutes.` | ||
| : `${code} is your Mozilla recovery code. Expires in 5 minutes.`; | ||
| const l10nTypeMap = { | ||
| setup: { |
There was a problem hiding this comment.
I do really like the flexibility of this 👍🏽
1caa3ee to
82915e3
Compare
vbudhram
left a comment
There was a problem hiding this comment.
I had to resolve some merge conflicts on main, but made the recommended changes. Wouldn't hurt to have another set of eyes.
bcolsson
left a comment
There was a problem hiding this comment.
These strings should still probably use the brand term
| # https://twiliodeved.github.io/message-segment-calculator/ | ||
| # Messages should be limited to one segment | ||
| # $code - 6 digit code used to verify phone ownership when registering a recovery phone | ||
| recovery-phone-setup-sms-short-body = Mozilla verification code: ${code} |
There was a problem hiding this comment.
This should use the brand term for Mozilla. Additionally - placeholders should be formatted as { $variable }
| # https://twiliodeved.github.io/message-segment-calculator/ | ||
| # Messages should be limited to one segment | ||
| # $code - 6 digit code used to verify phone ownership when registering a recovery phone | ||
| recovery-phone-setup-sms-short-body = Mozilla code: ${code} No newline at end of file |
There was a problem hiding this comment.
This should use the brand term for Mozilla. Additionally - placeholders should be formatted as { $variable }
There was a problem hiding this comment.
Id should be recovery-phone-signin-sms-short-body.
vpomerleau
left a comment
There was a problem hiding this comment.
Spotted a ftl id mismatch, other comments are mainly questions/nits that are not blocking.
| env: 'RECOVERY_PHONE__SMS__MAX_MESSAGE_LENGTH', | ||
| maxMessageSegmentLength: { | ||
| default: 1, | ||
| doc: 'Max allows sms message segment length', |
There was a problem hiding this comment.
Nit
| doc: 'Max allows sms message segment length', | |
| doc: 'Max allowed sms message segment length', |
| # https://twiliodeved.github.io/message-segment-calculator/ | ||
| # Messages should be limited to one segment | ||
| # $code - 6 digit code used to verify phone ownership when registering a recovery phone | ||
| recovery-phone-setup-sms-short-body = Mozilla code: ${code} No newline at end of file |
There was a problem hiding this comment.
Id should be recovery-phone-signin-sms-short-body.
| ? `${code} is your Mozilla verification code. Expires in 5 minutes.` | ||
| : `${code} is your Mozilla recovery code. Expires in 5 minutes.`; | ||
| const l10nTypeMap = { | ||
| setup: { |
| return { | ||
| msg: localizedMessage, | ||
| shortMsg: shortLocalizedMessage, | ||
| failsafeMsg: `Mozilla: ${code}`, |
There was a problem hiding this comment.
Using this failsafe all the time would save a lot of trouble 😅
| it('handles message template when provided to set up phone number', async () => { | ||
| mockOtpManager.generateCode.mockReturnValue(code); | ||
| const getFormattedMessage = jest.fn().mockResolvedValue('message'); | ||
| // const getFormattedMessage = jest.fn().mockResolvedValue('message'); |
| '${code} is your Mozilla recovery code. Expires in 5 minutes.', | ||
| }, | ||
| 'signin-short': { | ||
| id: 'recovery-phone-setup-sms-short-body', |
There was a problem hiding this comment.
| id: 'recovery-phone-setup-sms-short-body', | |
| id: 'recovery-phone-signin-sms-short-body', |
| # https://twiliodeved.github.io/message-segment-calculator/ | ||
| # Messages should be limited to one segment | ||
| # $code - 6 digit code used to verify phone ownership when registering a recovery phone | ||
| recovery-phone-setup-sms-short-body = { -brand-mozilla } code: { $code } No newline at end of file |
There was a problem hiding this comment.
| recovery-phone-setup-sms-short-body = { -brand-mozilla } code: { $code } | |
| recovery-phone-signin-sms-short-body = { -brand-mozilla } code: { $code } |
| # Shorter message sent by SMS with limited character length, please test translation with the messaging segment calculator | ||
| # https://twiliodeved.github.io/message-segment-calculator/ | ||
| # Messages should be limited to one segment | ||
| # $code - 6 digit code used to verify phone ownership when registering a recovery phone |
There was a problem hiding this comment.
| # $code - 6 digit code used to verify phone ownership when registering a recovery phone | |
| # $code - 6 digit code used to sign in with a recovery phone as backup for two-step authentication |
| // Pick the message with the best length and send it | ||
| const formattedMessages = await getFormattedMessages(code); | ||
| const body = this.getSafeSmsBody(formattedMessages); | ||
| const msg = await this.smsManager.sendSMS({ |
There was a problem hiding this comment.
Should this be wrapped in a try/catch block to prevent MessageBodyTooLong errors (though unlikely) from bubbling up to the user?
There was a problem hiding this comment.
I'll punt on that for now, maybe ok to fail hard and fast here.
Because: - We want the messages we send out to be under one gsm segment in length - Length isn't straightforwards. It varies based on encoding. - Language translation may impact length. This Commit: - Adds fallbacks for 'formatted messages' - Adds ability to determine sms segment length - Removes some stray logs found in session.js - Changes config to specify max segment length
Because
This pull request
session.jsIssue that this pull request solves
Closes: FXA-11072
Checklist
Put an
xin the boxes that applyScreenshots (Optional)
Please attach the screenshots of the changes made in case of change in user interface.
Other information (Optional)
Any other information that is important to this pull request.