-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure performed by is set for activities (#628)
<!--- Provide a general summary of your changes in the Title above --> Before refactoring more, let's do a review on this if this is the best approach or not.. ## Description <!--- Describe your changes in detail --> - Adds a new function to get the long names of the organization - Caches the result with a new cache key ## Related Issue(s) - #404 ## Verification - [X] **Your** code builds clean without any errors or warnings - [X] Manual testing done (required) - [ ] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [X] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) --------- Co-authored-by: Ole Jørgen Skogstad <[email protected]> Co-authored-by: Magnus Sandgren <[email protected]>
- Loading branch information
1 parent
434dd43
commit 1adf075
Showing
8 changed files
with
114 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
35 changes: 35 additions & 0 deletions
35
src/Digdir.Domain.Dialogporten.Application/Common/Services/DialogActivityService.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Activities; | ||
using Digdir.Domain.Dialogporten.Domain.Localizations; | ||
|
||
namespace Digdir.Domain.Dialogporten.Application.Common.Services; | ||
|
||
public interface IDialogActivityService | ||
{ | ||
Task EnsurePerformedByIsSetForActivities(IEnumerable<DialogActivity> activities, CancellationToken cancellationToken); | ||
} | ||
|
||
public class DialogActivityService : IDialogActivityService | ||
{ | ||
private readonly IUserOrganizationRegistry _userOrganizationRegistry; | ||
|
||
public DialogActivityService( | ||
IUserOrganizationRegistry userOrganizationRegistry | ||
) | ||
{ | ||
_userOrganizationRegistry = userOrganizationRegistry; | ||
} | ||
|
||
public async Task EnsurePerformedByIsSetForActivities(IEnumerable<DialogActivity> activities, CancellationToken cancellationToken) | ||
{ | ||
// TODO: if organization cannot be found we need to handle this. Put on a queue to be retried later(?) https://github.com/digdir/dialogporten/issues/639 | ||
foreach (var activity in activities) | ||
{ | ||
var organizationLongNames = await _userOrganizationRegistry.GetCurrentUserOrgLongNames(cancellationToken); | ||
activity.PerformedBy ??= new DialogActivityPerformedBy | ||
{ | ||
Localizations = organizationLongNames?.Select(x => new Localization { Value = x.LongName, CultureCode = x.Language }).ToList() ?? new List<Localization>(), | ||
}; | ||
} | ||
} | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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