Conversation
Move expiry calculation to verify function
5 tasks
|
sundflux
approved these changes
Mar 9, 2026
hyrsky
added a commit
that referenced
this pull request
Mar 19, 2026
* Validate SMS format before saving to ATV Update REST example with SMS * Add SMS collection Update gitignore * Add script to send sms Fix typo in readme * Add Dialogi SMS plugin and sms queue script. never tested, totally blind coded. test when api available * Set review database variables by Ansible scripts * Add missing sms queue generating in populate script, test script for sending sms and sms templates * Target url was wrong * Add some missing stuff to dialogi * add validateElasticQuery to validate queries sent to hakuvahti * Update helfi-hakuvahti-dev.yml * Use correct CMD in dockerfile * Silence fastify default logging for health routes * Delete pipelines/helfi-hakuvahti-review.yml Review environments don't work with our mongo yet, so let's enable this without review trigger. * Remove lint:check from build * Fix nodemailer security * feat: Add optional SMS parameter to subscription API - Add optional 'sms' field to SubscriptionRequest schema - Validate SMS in international E.164 format (e.g., +358451234567) - Store SMS with email in same ATV document for security - Move all validation logic to route layer for cleaner architecture - Remove email validation from ATV plugin (now pure storage layer) SMS is optional and stored encrypted in ATV alongside email. Only the ATV document ID is saved to MongoDB, maintaining data separation. * Move validation funcs to controller * Validate SMS format before saving to ATV Update REST example with SMS * Add SMS collection Update gitignore * Add script to send sms Fix typo in readme * Add Dialogi SMS plugin and sms queue script. never tested, totally blind coded. test when api available * Add missing sms queue generating in populate script, test script for sending sms and sms templates * Target url was wrong * Add some missing stuff to dialogi * Return object type according to documentation, hope its correct * Add dummy server for sms testing * log sms message id * Log messageid but not destination * Remove some logging * Add a fix script for bug UHF-12396 * Remove lint from build, node mailer update was not committed for some reason * Update dialog api url to be correct * Cron bash scripts not needed anymore * Rename populate script * Rename populate script, implement limit of results in email, quick feature request by Aleksi * Get rid of ATV call in populate loop by adding a simple has_sms flag to the subscription document. * Implement subscription status * Implement hakuvahti renewe * Update sonarcube * Update ATV document with renew * Okay, sending ALL fields to ATV makes the API fail with very descriptive 400 Bad Request. Fixed by sending only writable fields * Biome formatting * Fix failing test, we use local now instead of dev, also elasticProxyUrl is required parameter * Biome wants formatting * Add test for renewSubscription * Hotfix, remove duplicate type. No idea how this got through * Update node version to match the one deployed to openshift * Move c8 to devDependencies C8 seems to be related to coverate calculations: https://www.npmjs.com/package/c8 * Remove redundant npm run copy:assets calls from defined commands * Run tests on CI * Remove useless override of make up * Simplify tools * Add github reporter to lint check * Simplify testing * Simplify docker compose network * Debug tests * Update c8 * Try test-force-exit * Add timeout * Try this * Add --ignore-scripts * Cleanup * Fix typo * Resolve sonarcloud issues * Add editorconfig * Remove legacy pipeline files * Fix typo * Remove console script boilerplate code * Remove @types/tap * Update @types/node to match current NodeJS version * Run tests only from *.test.ts * Add tests for src/lib/command.ts * Add process manager wrapper for development container The Fastify dev server was running directly as PID 1 in the Docker container, causing the entire container to exit when the process crashed. This commit adds a simple shell script wrapper that keeps the container alive by automatically restarting the application process after crashes. * Add tests for /subscription/confirm and /subscription/delete APIs This also updated fastify plugins. I could not figure out how to access plugins in the older version. In version 5, plugins are available to tests if { skipOverride: true } is passed to the app configuration. See test/helper.ts for more details. * Various notes * Fix renewSubscription.test.ts Fix the test now that mongodb connection actually works. The test was previously just skipped. * Add tests for /subscription/status * Add tests for probes * Run biome fix * Add tests for email sending Refactor email testing to a service class so that it is possible to test * Remove env variables that should not be changed from .env file * Misc comments * Simplify signature, rely on type inference * Add tests for sms sending * Various comments * Fix race condition in the tests * Fix sms test too * Add email translations and template system improvements - Add translations object to rekry.json config with email subjects and instructions in fi/en/sv - Implement translation helper functions in email.ts (translate, buildTranslationContext) - Update wrapWithLayout to accept title parameter and pass translations to templates - Add date variables (year, month, day) to layout context - Update all email functions to use translated subjects - Add translations support to SiteConfiguration type and loader - Add Helsinki logo SVG to footer with responsive stacking layout - Update footer to include copyright with dynamic year variable and instructions link - Convert text links to styled button components with black background - Add responsive CSS for footer branding on mobile - Export template functions so tests can use them - Add tests for email templates and translations - Refactor all translation strings to json translations and make unified template for all languages. * Add api key to hakuvahti * Add tests /subscription route * Add text reporter to test command * Install node_modules with correct permissions Run the docker container as the current user, so all files created in the container are created with correct permissions. * Debug permissions * Add some more padding * Remove for now, although could be used for datestamps in mail.. * Update new content and translations * Fix dependabot security issue * Sonarcloud * Simplify the email templates html structure a bit, add comprehensive inline styles, fix the layout to look the way it was designed * Add test script to test all email templates * Biome lint * Bump target to ES2020 as ES5 complains about command() structure * Make preValidation non-async * Adjust new hits email base layouts * New email texts * New text tags for templates * Move expiry date calculation so newhits template can also use it * Add expiry_date to newhits * Add expiry date to test script * Adjust new hits email base layouts * Fix translation tag name typo * Add renewal_link to expiry mail * Add renewal_link to test script * Add renewal link to populate script * These translations are missing so temporary about so-so texts for expiry * update expiry notification style * Add missing variables to expiry template and new texts * Update ATV addresses * Update subjects * Fix sonarcloud warning, tyopeof unnecessary * Add couple tests to increase coverage * Try adding minimal smoke test for coverage * Well that didn't affect coverage at all * Refactor test email script to have testable function and add test for it. * Lets see what happens in sonarcloud now * Add typing for this should finally fix sonarcloud * For staging, change expire notification to happen after 1 day * Expire dev subscriptions also within a day * Add fromDate parameter to atv delete_after updating + update renewSubscription to include new parameter, defaults to current date * Add update subscription length script. Add tests for exported functions. API key variable was missing from container, making requests fail. * Biome lint * Add this to separate PR * Fix review comments: parameters from command argv, biome doesn't need no-console rule, throw error on error so command catches it * Move prints and date formatting to own functions for test coverage * Refactor a bit for test coverage, command wrapper now handles errors and exit, removed redurant error handling * parseArgs got dead in command argv change. shorten dryRun logic * Remove test noise * Add scripts to exclude that should not be tested * Coverage exclusion * SQ tuning * Translate copyright holder too * Add logo image link to translations * Replace SVG logo with png logo * Brain error: expiryNotificationDays does not mean sending notifications after X days, it means send notification X days before ending * Add production instruction links * production subscription length to 6 months, notification 5 days before expire * Update helfi-hakuvahti-release.yml * Update helfi-hakuvahti-release.yml * Remove migration scripts * remove scripts from sonarcloud exclude * Updated the email texts for the rekry saved search * Add delete_after to types * Add delete_after in renew and addsubscription to mongo * Calculate in populate script if the delete_after needs to be synced * Couple simple tests to test calculateExpectedDeleteAfter and needsDeleteAfterSync * Test delete_after in renew and addSubscription * Nodemaile Security Update * Link to smaller email logos * Add npm audit to pipelines (#70) * Updated lodash and diff. * Refactor ATV a bit, we are saving more stuff to ATV so createDocumentWithEmail should be just generic * Validate elastic query also from _atv variable. If sent this way, the document gets saved to ATV * Refactor API after all, no extra validation needed here.. * Create ATV document for query if elastic_query_atv is ste in request * Load query from ATV if elastic_query_atv flag is set * update tests for elastic_search_atv 1 flag * biome * update fastify * Change ElasticSearch url * security update * Update production URL for Elastic * Add placeholder config for kymp (#76) * We need to refresh the code for subscription if SMS is enabled on populate so it can be sent via SMS * Expose sms_code for sms templates * Generate SMS code if SMS is enabled * New site configuration vars * renewal types + sms stuff * smsCode lib for generating + validating SMS code * Verification types * SMS verification * move some subscription logic from controllers so we can reuse it with SMS * Add simple in-memory rate limit for verifications * Add sms routes for actions * Test for smsCode * rate limit test * Test requests * Enable sms for local rekry for testing * Refactoring for code reviews * lint * refactoring a bit, combine smscode + smsverification to single class, cleaning types * fix loading sms code * remove rate limit, fix loading sms code after rebase * tests * linter * Security update * Change ElasticSearch url * Add placeholder config for kymp * Enable sms * Use docker service URLs * Allow empty emails in hakuvahti * Support sms subscriptions * Lint * Fix tests * big bunch of translations * translations * sms templates * this not needed * confirmation template * newhits sms * add renewal sms template with data * linter and cleanup * remove from here, no link in sms anymore * Patch GHSA-2g4f-4pwh-qvx6 * Replace c8 with nodejs native coverage --------- Co-authored-by: Tarmo Sundström <tarmo.sundstrom@druid.fi> * Testing conf * Fix kymp elasticsearch URL (#79) * Fix sms sending & refactor queue implementation (#80) * Fix sms sending * Enable SMS for kymp test * Merge both queues together * add staging+prod configs and missing urls for SMSes * remove lang urls * add config option for target field to match for results * matchField type * add fieldformatters for elastic data for templates * fieldFormats type * cleanup, we don't need partial node typed anymore * add support for matchField, get rid of partialdrupalnodetype * templates for hits instead of using link stuff and making layout in code * this goes through hit_item now * clean drupalnodetype * urls * move formatters for root leve * get rid of hardcoded defaults * move formatters in structure * fix matchField in tests * Add easier test script that doesn't need ATV * hit template for sms * cleanup, this is unused * newhit template for sms * newhits sms * add missing hits from sms * hits must be in structure * ignore test scripts in coverage * update short links * this actually matched *test* directive already. no effect * add tests for SMS hits * UHF-12838 (#84) * Allow confirming sms subscription individually from email subscriptions * Simplify createSmsHandler Move expiry calculation to verify function * Simplify verifySmsRequest * Cleanup confusing ATV id fields * Simplify site configuration loader * Simplify elastic query storing in ATV * Simplify ATV document generation * Use better random number generator * Refactor ATV plugin * Cleanup logging * Simplify errlor handling for sms endpoints * Unify subscription actions between sms and email notifications * Store user data in ATV properly * Remove unused plugin * Improve tests * Allow non-unique sms codes * Cleanup * Patch GHSA-573f-x89g-hqp9 * Return 409 if subscription is already active * Update short URLs for testing (#85) Hakuvahti is in internal testing phase. Revert this change before going to production. * Remove instructions link * Properly newline the SMS messages * removal sign location text (#89) * Improve logging and error handling, fix date formatting (#88) * Improve logging * Fix incorrect timezone on results message * Format * update siirtovahti > Siirtovahti --------- Co-authored-by: Tarmo Sundström <tarmo.sundstrom@druid.fi> * Revert "Update short URLs for testing (#85)" (#86) This reverts commit 84a3c0a. --------- Co-authored-by: Tarmo Sundström <tarmo.sundstrom@druid.fi> Co-authored-by: Lundelin Joonas <lundejo@HIQ-199279.localdomain> Co-authored-by: Tero Elonen <tero.elonen@druid.fi> Co-authored-by: Tero Elonen <2276077+teroelonen@users.noreply.github.com> Co-authored-by: Markus Kalijärvi <markus.kalijarvi@druid.fi>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Bug fixes:
Refactoring:
Links to related PRs