Commit edf0c47
expire_imminent: route resource.expiry_imminent through Go renderer
User got the broken "Your resource expires in 6 hours" email again
after the first fix shipped. Worker log proved it: BOTH expiry kinds
fired for the same recipient at 04:12:56 UTC:
kind=anon.expiry_warning path=raw_html template_id=0 (new fix)
kind=resource.expiry_imminent path=template template_id=6 (still broken)
The first fix only registered renderAnonExpiryEmail for
anon.expiry_warning. The sibling kind from expire_imminent.go
(authenticated/paid resources) was still routed through Brevo's
templateId=6 — the same template that hardcodes "6 hours" + reads
param names we don't emit (empty Type/Token/Expires rows).
Fix:
- Register renderAnonExpiryEmail for resource.expiry_imminent in
eventEmailBodyRenderers. Same renderer — both kinds have identical
user-facing semantics ("your resource expires in N hours, click to
keep") and the renderer treats missing optional params as empty.
- Extend buildResourceExpiring to emit upgrade_url, resource_url,
token_prefix, reminder_index="1" (single-fire — paid path has no
stage concept) + audit_kind so the renderer view struct fills.
- Extend expire_imminent.go's audit insert to populate the same
metadata fields (token_prefix is first 8 chars of r.token only,
never the full secret; upgrade_url carries source=
resource_expiry_imminent for funnel attribution).
Tests:
- TestEventEmailBodyRenderers_CoversBothExpiryKinds: regression guard
that fails if either expiry kind isn't registered. Catches the
exact bug class that bit us today.
- TestBuildResourceExpiring_EmitsAllRendererParams: asserts every
renderer-required key is non-empty after the build.
- All 9 targeted tests pass; ./internal/jobs/... ./internal/email/...
full suite green (ok 22.533s + 0.544s).
The Brevo template_id=6 fallback in BREVO_TEMPLATE_IDS is left in
place — brevo_provider.go::SendEvent prefers HTMLBody != "" so any
legacy events queued before this deploy still route through the new
path; the templateId is harmless dead-code for new sends.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2ad8e22 commit edf0c47
3 files changed
Lines changed: 110 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
206 | 215 | | |
207 | | - | |
| 216 | + | |
| 217 | + | |
208 | 218 | | |
209 | 219 | | |
210 | 220 | | |
| |||
334 | 344 | | |
335 | 345 | | |
336 | 346 | | |
| 347 | + | |
337 | 348 | | |
338 | 349 | | |
339 | 350 | | |
340 | 351 | | |
341 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
342 | 368 | | |
343 | 369 | | |
344 | 370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
229 | 242 | | |
230 | 243 | | |
231 | 244 | | |
232 | 245 | | |
233 | 246 | | |
234 | 247 | | |
235 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
236 | 252 | | |
237 | 253 | | |
238 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
151 | 216 | | |
152 | 217 | | |
153 | 218 | | |
| |||
0 commit comments