Skip to content

Instantiation notification api approach#1679

Merged
HauklandJ merged 62 commits intomainfrom
instantiation-notification-api-approach
Mar 18, 2026
Merged

Instantiation notification api approach#1679
HauklandJ merged 62 commits intomainfrom
instantiation-notification-api-approach

Conversation

@HauklandJ
Copy link
Copy Markdown
Contributor

@HauklandJ HauklandJ commented Feb 25, 2026

Description

Specify a notification to send to the instance owner on instansiation.

Individuals -> language fetched from profile
Organizations -> language supplied in the instansiation request (fallback to Nb as default)

https://docs.altinn.studio/nb/altinn-studio/v8/reference/api/temp/

Plan:

First preview without requested send time, reminders or custom cancel logic ✅
Second preview with requested send time and reminders with default notification cancellation (process has ended) ✅
Third preview with custom cancel logic ✅

Related Issue(s)

  • #{issue number}

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • New Features
    • Optional notifications on instance creation and copy: include structured notification payloads to send email/SMS to the instance owner.
    • Customizable multilingual messages (Bokmål, Nynorsk, English) with token-based personalization (app name, owner, org/SSN, due date).
    • Selectable delivery channels, per-language sender/subject/body, and improved language selection for accurate localization.
    • API schema extended to accept and return the new notification structures.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds end-to-end instantiation notification support: new notification models, clients, service and interfaces; DI registrations; telemetry; controller wiring to trigger notifications on create/copy; profile/party/CDN client extensions; text/token utilities; exceptions; tests and OpenAPI updates.

Changes

Cohort / File(s) Summary
Controller integration & API model
src/Altinn.App.Api/Controllers/InstancesController.cs, src/Altinn.App.Api/Models/InstansiationInstance.cs
Wires INotificationService into InstancesController, extracts optional InstansiationNotification from multipart request parts, triggers notifications on instantiation and copy flows; adds Notification property to InstansiationInstance.
DI registration
src/Altinn.App.Core/Extensions/ServiceCollectionExtensions.cs
Registers INotificationOrderClient HttpClient and INotificationService implementation in DI.
Notification service & interfaces
src/Altinn.App.Core/Features/Notifications/INotificationService.cs, src/Altinn.App.Core/Features/Notifications/NotificationService.cs
Adds INotificationService and NotificationService that resolve language/recipient, compose NotificationOrderRequest, and order notifications via the order client.
Order & cancel clients
src/Altinn.App.Core/Features/Notifications/Future/NotificationOrderClient.cs, src/Altinn.App.Core/Features/Notifications/Order/NotificationCancelClient.cs
Implements HTTP clients to place and cancel future notification orders with telemetry, platform auth, response handling and specialized exceptions.
Notification models & exceptions
src/Altinn.App.Core/Models/Notifications/Future/*, src/Altinn.App.Core/Models/Notifications/Order/*
Introduces comprehensive Future notification models (InstansiationNotification, CustomEmail/Sms/Text, NotificationOrderRequest/Response, enums, recipient types) and exceptions (NotificationOrderException, NotificationCancelException).
Text utilities & tokens
src/Altinn.App.Core/Features/Notifications/Texts/NotificationTexts.cs, src/Altinn.App.Core/Features/Notifications/Texts/ReplacementTokens.cs
Adds localized default subject/body generation and token-replacement helpers plus replacement token constants.
Telemetry
src/Altinn.App.Core/Features/Telemetry/Telemetry.Notifications.cs, src/Altinn.App.Core/Features/Telemetry/Telemetry.cs
Adds cancellation telemetry and metric, extends OrderType with Future, and adds label notification.sendersReference.
Profile / party / CDN client extensions
src/Altinn.App.Core/Infrastructure/Clients/Profile/..., src/Altinn.App.Core/Internal/.../IAltinnPartyClient.cs, src/Altinn.App.Core/Internal/AltinnCdn/...
Adds GetUserProfile(Guid) overloads, GetPartyUuidByUrn(string) and GetOrgNameByAppId(string) methods plus related null guards and language-aware org-name lookup.
Tests, fixtures & mocks
test/Altinn.App.Core.Tests/Features/Notifications/*, test/Altinn.App.Api.Tests/Controllers/InstancesControllerFixture.cs, test/Altinn.App.Tests.Common/Mocks/*, test/*_snapshots/*, test/Altinn.App.Analyzers.Tests/...
Adds unit tests for notification service and texts, registers/verifies INotificationService mock in fixtures, adds mock stubs, updates integration snapshots (Content-Length changes), and extends analyzer test timeouts.
OpenAPI & public API verifications
test/Altinn.App.Api.Tests/OpenApi/OpenApiSpecChangeDetection.SaveJsonSwagger.verified.json, test/*PublicApi*
Updates OpenAPI schema with notification-related components and updates public API verification files to include new constructor parameter and InstansiationInstance.notification property.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.61% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Instantiation notification api approach' clearly refers to the main feature being introduced: adding optional notification support to the instantiation API. It accurately describes the primary change from the developer's perspective.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch instantiation-notification-api-approach
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HauklandJ HauklandJ added squad/data Issues that belongs to the named squad. feature Label Pull requests with new features. Used when generation releasenotes org/brg Issues relevant for Brønnøysundregistrene. labels Feb 25, 2026
@HauklandJ HauklandJ moved this to 👷 In progress in Team Altinn Studio Feb 25, 2026
@HauklandJ HauklandJ added the backport-ignore This PR is a new feature and should not be cherry-picked onto release branches label Feb 25, 2026
Comment thread src/Altinn.App.Api/Controllers/InstancesController.cs Fixed
Comment thread src/Altinn.App.Core/Features/Notifications/Future/NotificationOrderClient.cs Dismissed
Comment thread src/Altinn.App.Core/Features/Notifications/Order/NotificationCancelClient.cs Dismissed
@HauklandJ HauklandJ force-pushed the instantiation-notification-api-approach branch 2 times, most recently from efeed98 to 306256e Compare March 2, 2026 09:04
@HauklandJ HauklandJ force-pushed the instantiation-notification-api-approach branch from 306256e to ac2d9fd Compare March 2, 2026 12:44
@HauklandJ
Copy link
Copy Markdown
Contributor Author

/publish

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 16, 2026

PR release:

⚙️ Building...
✅ Done!

Copy link
Copy Markdown
Contributor

@Konrad-Simso Konrad-Simso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing previous comment since logging has been removed.

Comment thread test/Altinn.App.Core.Tests/Features/Notifications/Order/NotificationClientTests.cs Dismissed
Comment thread test/Altinn.App.Core.Tests/Features/Notifications/Order/NotificationClientTests.cs Dismissed
Comment thread test/Altinn.App.Core.Tests/Features/Notifications/Order/NotificationClientTests.cs Dismissed
Comment thread test/Altinn.App.Core.Tests/Features/Notifications/Order/NotificationClientTests.cs Dismissed
Comment thread test/Altinn.App.Core.Tests/Features/Notifications/Order/NotificationClientTests.cs Dismissed
@HauklandJ HauklandJ moved this from 👷 In progress to 🔎 In review in Team Altinn Studio Mar 18, 2026
Copy link
Copy Markdown
Contributor

@Konrad-Simso Konrad-Simso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good start, some comments on clean up or missing info, the logic seems well thought out! 🚀

Comment thread src/Altinn.App.Core/Features/Notifications/NotificationService.cs Outdated
Comment thread src/Altinn.App.Core/Features/Notifications/NotificationService.cs Outdated
Comment thread src/Altinn.App.Core/Features/Notifications/NotificationService.cs Outdated
Comment thread src/Altinn.App.Core/Features/Notifications/NotificationService.cs Outdated
Comment thread src/Altinn.App.Core/Features/INotificationOrderClient.cs Outdated
Comment thread src/Altinn.App.Core/Features/Notifications/NotificationService.cs
Comment thread src/Altinn.App.Core/Features/Notifications/NotificationService.cs Outdated
Comment thread test/Altinn.App.Core.Tests/Features/Notifications/NotificationServiceTests.cs Outdated
@sonarqubecloud
Copy link
Copy Markdown

@Konrad-Simso Konrad-Simso removed their assignment Mar 18, 2026
@Konrad-Simso Konrad-Simso moved this from 🔎 In review to 🧪 Test in Team Altinn Studio Mar 18, 2026
@HauklandJ HauklandJ merged commit c8f17e6 into main Mar 18, 2026
13 checks passed
@HauklandJ HauklandJ deleted the instantiation-notification-api-approach branch March 18, 2026 11:03
@github-project-automation github-project-automation Bot moved this from 🧪 Test to ✅ Done in Team Altinn Studio Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-ignore This PR is a new feature and should not be cherry-picked onto release branches feature Label Pull requests with new features. Used when generation releasenotes org/brg Issues relevant for Brønnøysundregistrene. squad/data Issues that belongs to the named squad.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants