-
Notifications
You must be signed in to change notification settings - Fork 83
Issue582 #597
Issue582 #597
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,27 +180,39 @@ | |
{{if $realm.EnableENExpress}} | ||
Your SMS template <em>MUST</em> contain <code>[enslink]</code>. | ||
<ul> | ||
<li><code>[enslink]</code> Inserts the required EN Express link of: <code>ens://v?r=[region]&c=[longcode]</code></li> | ||
{{if eq "" .enxRedirectDomain}} | ||
<li><code>[enslink]</code> Inserts the required EN Express link of: <code>ens://v?r=[region]&c=[longcode]</code></li> <li><code>[enslink]</code> Inserts the required EN Express link of: <code>ens://v?r=[region]&c=[longcode]</code></li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like this line is twice (see column like 120) |
||
{{else}} | ||
<li><code>[enslink]</code> Inserts the EN Express link of: <code>https://{{toLower $realm.RegionCode}}.{{.enxRedirectDomain}}/v?c=[longcode]</code> | ||
<ul> | ||
<li>This domain should be registered as a universal link for both your Android and iOS applications.</li> | ||
<li>Contact your server operator to verify the the verification EN Express redirect service is running and configurd correctly.</li> | ||
</ul> | ||
</li> | ||
{{end}} | ||
<li><code>[longexpires]</code>The number of hours until the long code expires (just the number, no units).</li> | ||
</ul> | ||
|
||
Here is an example SMS template using EN Express. | ||
|
||
<ul> | ||
<li> | ||
<p>Custom greeting before the EN Express link and showing expiration. | ||
This is <code>145</code> characters when expanded.</p> | ||
<p>Custom greeting before the EN Express link and showing expiration.</p> | ||
<p> | ||
<samp class="text-dark"> | ||
State of Wonder Dept. of Health. Click to share anonymous data for exposure notifications [enslink] Expires in [longexpires] hours | ||
State of Wonder DOH. Click to share anonymous data for exposure notifications [enslink] (mobile only) Expires in [longexpires] hours | ||
</samp> | ||
</p> | ||
</li> | ||
<li> | ||
<p>This results in a SMS message that looks like:</p> | ||
<p> | ||
<samp class="text-dark"> | ||
State of Wonder Dept. of Health. Click to share anonymous data for exposure notifications ens://v?r=US-XX&c=12345678abcd1234 Expires in 24 hours | ||
{{if eq "" .enxRedirectDomain}} | ||
State of Wonder DOH. Click to share anonymous data for exposure notifications ens://v?r={{$realm.RegionCode}}&c=[longcode] (mobile only) Expires in 24 hours | ||
{{else}} | ||
State of Wonder DOH. Click to share anonymous data for exposure notifications https://{{toLower $realm.RegionCode}}.{{.enxRedirectDomain}}/v?c=[longcode] (mobile only) Expires in 24 hours | ||
{{end}} | ||
</samp> | ||
</p> | ||
</li> | ||
|
@@ -231,12 +243,15 @@ | |
</p> | ||
</li> | ||
<li> | ||
<p>Send long code with custom URI (<code>152</code> characters with 16 digit codes and 24 hour expiration):</p> | ||
<p>Send long code with custom URI (<code>152</code> characters with 16 digit codes and 24 hour expiration). | ||
Here we assume that <code>verify.mypha.gov</code> is registred as a universal link for both your iOS | ||
and Android applications. | ||
</p> | ||
<p> | ||
<samp class="text-dark"> | ||
You have tested positive for Covid-19. Click here to | ||
You have tested positive for COVID-19. Click here to | ||
share anonymous data for exposure notifications | ||
dohen://v?c=[longcode] (Expires in [longexpires] hours) | ||
https://verify.mypha.gov/v?c=[longcode] (Expires in [longexpires] hours) | ||
</samp> | ||
</p> | ||
</li> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ type Realm struct { | |
LongCodeLength uint `gorm:"type:smallint; not null; default: 16"` | ||
LongCodeDuration DurationSeconds `gorm:"type:bigint; not null; default: 86400"` // default 24h | ||
// SMS Content | ||
SMSTextTemplate string `gorm:"type:varchar(400); not null; default: 'This is your Exposure Notifications Verification code: ens://v?r=[region]&c=[longcode] Expires in [longexpires] hours'"` | ||
SMSTextTemplate string `gorm:"type:varchar(400); not null; default: 'This is your Exposure Notifications Verification code: [longcode] Expires in [longexpires] hours'"` | ||
|
||
// WelcomeMessage is arbitrary realm-defined data to display to users after | ||
// selecting this realm. If empty, nothing is displayed. The format is | ||
|
@@ -173,7 +173,7 @@ func NewRealmWithDefaults(name string) *Realm { | |
CodeDuration: FromDuration(15 * time.Minute), | ||
LongCodeLength: 16, | ||
LongCodeDuration: FromDuration(24 * time.Hour), | ||
SMSTextTemplate: "This is your Exposure Notifications Verification code: ens://v?r=[region]&c=[longcode] Expires in [longexpires] hours", | ||
SMSTextTemplate: "This is your Exposure Notifications Verification code: [longcode] Expires in [longexpires] hours", | ||
AllowedTestTypes: 14, | ||
CertificateDuration: FromDuration(15 * time.Minute), | ||
} | ||
|
@@ -294,10 +294,19 @@ func (r *Realm) GetLongCodeDurationHours() int { | |
} | ||
|
||
// BuildSMSText replaces certain strings with the right values. | ||
func (r *Realm) BuildSMSText(code, longCode string) string { | ||
func (r *Realm) BuildSMSText(code, longCode string, enxDomain string) string { | ||
text := r.SMSTextTemplate | ||
|
||
text = strings.ReplaceAll(text, SMSENExpressLink, fmt.Sprintf("ens://v?r=%s&c=%s", SMSRegion, SMSLongCode)) | ||
if enxDomain == "" { | ||
// preserves legacy behavior. | ||
text = strings.ReplaceAll(text, SMSENExpressLink, fmt.Sprintf("ens://v?r=%s&c=%s", SMSRegion, SMSLongCode)) | ||
} else { | ||
text = strings.ReplaceAll(text, SMSENExpressLink, | ||
fmt.Sprintf("https://%s.%s/v?c=%s", | ||
strings.ToLower(r.RegionCode), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we currently enforce uniqueness on region codes right now, just realm names. Should we add a database constraint for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can file an issue for that. I'm not confident it would help anything since it's only specific to one sever |
||
enxDomain, | ||
SMSLongCode)) | ||
} | ||
text = strings.ReplaceAll(text, SMSRegion, r.RegionCode) | ||
text = strings.ReplaceAll(text, SMSCode, code) | ||
text = strings.ReplaceAll(text, SMSExpires, fmt.Sprintf("%d", r.GetCodeDurationMinutes())) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just do
{{if .enxRedirectDomain}}