Skip to content

Commit ca18a99

Browse files
feat(webapi): Combine actorDtos (#1374)
## Description Replaced all actorDtos with one common enduser actordto, and one common serivceowner actordto ## Related Issue(s) ## Verification - [x] **Your** code builds clean without any errors or warnings - [x] Manual testing done (required) - [x] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] 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) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a unified `ActorDto` for actor representation across various components, replacing multiple specific actor DTOs. - Added validation for `ActorDto` to ensure proper data integrity based on actor type. - **Bug Fixes** - Updated mappings and properties to reflect the new actor structure, enhancing data consistency across the application. - **Documentation** - Updated Swagger configuration to reflect changes in actor representation. - **Tests** - Added comprehensive unit tests for the new `ActorValidator` to ensure validation rules are correctly enforced. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Amund Myrbostad <amund.myrbostad@digdir.no> Co-authored-by: Magnus Sandgren <5285192+MagnusSandgren@users.noreply.github.com>
1 parent e79dbfa commit ca18a99

File tree

49 files changed

+377
-1184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+377
-1184
lines changed

docs/schema/V1/swagger.verified.json

+79-561
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Digdir.Domain.Dialogporten.Domain.Actors;
2+
3+
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors;
4+
5+
public sealed class ActorDto
6+
{
7+
/// <summary>
8+
/// The type of actor that sent the transmission.
9+
/// </summary>
10+
public ActorType.Values ActorType { get; set; }
11+
12+
/// <summary>
13+
/// Specifies the name of the entity that sent the transmission. Mutually exclusive with ActorId. If ActorId
14+
/// is supplied, the name will be automatically populated from the name registries.
15+
/// </summary>
16+
/// <example>Ola Nordmann</example>
17+
public string? ActorName { get; set; }
18+
19+
/// <summary>
20+
/// The identifier of the person or organization that sent the transmission. Mutually exclusive with ActorName.
21+
/// Might be omitted if ActorType is "ServiceOwner".
22+
/// </summary>
23+
/// <example>urn:altinn:person:identifier-no:12018212345</example>
24+
public string? ActorId { get; set; }
25+
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using AutoMapper;
2+
using Digdir.Domain.Dialogporten.Application.Common;
3+
using Digdir.Domain.Dialogporten.Domain;
4+
using Digdir.Domain.Dialogporten.Domain.Actors;
5+
6+
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors;
7+
8+
internal sealed class MappingProfile : Profile
9+
{
10+
public MappingProfile()
11+
{
12+
13+
var actorDtoType = typeof(ActorDto);
14+
var actorType = typeof(Actor);
15+
16+
var derivedActorTypes = DomainAssemblyMarker
17+
.Assembly
18+
.GetTypes()
19+
.Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(actorType))
20+
.ToList();
21+
22+
CreateMap<Actor, ActorDto>()
23+
.ForMember(dest => dest.ActorType, opt => opt.MapFrom(src => src.ActorTypeId))
24+
.ForMember(dest => dest.ActorId, opt => opt.MapFrom(src => IdentifierMasker.GetMaybeMaskedIdentifier(src.ActorId)));
25+
26+
foreach (var outputActor in derivedActorTypes)
27+
{
28+
CreateMap(outputActor, actorDtoType)
29+
.IncludeBase(actorType, actorDtoType);
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Digdir.Domain.Dialogporten.Application.Features.V1.Common.Localizations;
2-
using Digdir.Domain.Dialogporten.Domain.Actors;
2+
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors;
33
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Activities;
44

55
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogActivities.Queries.Get;
@@ -14,14 +14,6 @@ public sealed class ActivityDto
1414

1515
public Guid? TransmissionId { get; set; }
1616

17-
public PerformedByActorDto PerformedBy { get; set; } = null!;
17+
public ActorDto PerformedBy { get; set; } = null!;
1818
public List<LocalizationDto> Description { get; set; } = [];
1919
}
20-
21-
public sealed class PerformedByActorDto
22-
{
23-
public Guid Id { get; set; }
24-
public ActorType.Values ActorType { get; set; }
25-
public string? ActorName { get; set; }
26-
public string? ActorId { get; set; }
27-
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using AutoMapper;
2-
using Digdir.Domain.Dialogporten.Application.Common;
32
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Activities;
43

54
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogActivities.Queries.Get;
@@ -11,8 +10,5 @@ public MappingProfile()
1110
CreateMap<DialogActivity, ActivityDto>()
1211
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src.TypeId));
1312

14-
CreateMap<DialogActivityPerformedByActor, PerformedByActorDto>()
15-
.ForMember(dest => dest.ActorType, opt => opt.MapFrom(src => src.ActorTypeId))
16-
.ForMember(dest => dest.ActorId, opt => opt.MapFrom(src => IdentifierMasker.GetMaybeMaskedIdentifier(src.ActorId)));
1713
}
1814
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors;
2+
13
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogLabelAssignmentLog.Queries.Search;
24

35
public sealed class LabelAssignmentLogDto
@@ -8,14 +10,6 @@ public sealed class LabelAssignmentLogDto
810

911
public string Action { get; set; } = null!;
1012

11-
public LabelAssignmentLogActorDto PerformedBy { get; set; } = null!;
12-
13-
}
14-
15-
public sealed class LabelAssignmentLogActorDto
16-
{
17-
18-
public string ActorName { get; set; } = null!;
13+
public ActorDto PerformedBy { get; set; } = null!;
1914

20-
public string ActorId { get; set; } = null!;
2115
}

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogLabelAssignmentLog/Queries/Search/MappingProfile.cs

-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ public sealed class MappingProfile : Profile
88
public MappingProfile()
99
{
1010
CreateMap<LabelAssignmentLog, LabelAssignmentLogDto>();
11-
CreateMap<LabelAssignmentLogActor, LabelAssignmentLogActorDto>();
1211
}
1312
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using AutoMapper;
2-
using Digdir.Domain.Dialogporten.Application.Common;
32
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
43

54
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSeenLogs.Queries.Get;
@@ -11,8 +10,5 @@ public MappingProfile()
1110
CreateMap<DialogSeenLog, SeenLogDto>()
1211
.ForMember(dest => dest.SeenAt, opt => opt.MapFrom(src => src.CreatedAt));
1312

14-
CreateMap<DialogSeenLogSeenByActor, SeenLogSeenByActorDto>()
15-
.ForMember(dest => dest.ActorId,
16-
opt => opt.MapFrom(src => IdentifierMasker.GetMaybeMaskedIdentifier(src.ActorId)));
1713
}
1814
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors;
2+
13
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSeenLogs.Queries.Get;
24

35
public sealed class SeenLogDto
46
{
57
public Guid Id { get; set; }
68
public DateTimeOffset SeenAt { get; set; }
7-
public SeenLogSeenByActorDto SeenBy { get; set; } = null!;
9+
public ActorDto SeenBy { get; set; } = null!;
810

911
public bool IsViaServiceOwner { get; set; }
1012
public bool IsCurrentEndUser { get; set; }
1113
}
1214

13-
public sealed class SeenLogSeenByActorDto
14-
{
15-
public Guid Id { get; set; }
16-
public string ActorName { get; set; } = null!;
17-
public string ActorId { get; set; } = null!;
18-
}

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogSeenLogs/Queries/Search/MappingProfile.cs

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using AutoMapper;
2-
using Digdir.Domain.Dialogporten.Application.Common;
32
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
43

54
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSeenLogs.Queries.Search;
@@ -11,7 +10,5 @@ public MappingProfile()
1110
CreateMap<DialogSeenLog, SeenLogDto>()
1211
.ForMember(dest => dest.SeenAt, opt => opt.MapFrom(src => src.CreatedAt));
1312

14-
CreateMap<DialogSeenLogSeenByActor, SeenLogSeenByActorDto>()
15-
.ForMember(dest => dest.ActorId, opt => opt.MapFrom(src => IdentifierMasker.GetMaybeMaskedIdentifier(src.ActorId)));
1613
}
1714
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1+
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors;
2+
13
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSeenLogs.Queries.Search;
24

35
public sealed class SeenLogDto
46
{
57
public Guid Id { get; set; }
68
public DateTimeOffset SeenAt { get; set; }
79

8-
public SeenLogSeenByActorDto SeenBy { get; set; } = null!;
10+
public ActorDto SeenBy { get; set; } = null!;
911

1012
public bool IsViaServiceOwner { get; set; }
1113
public bool IsCurrentEndUser { get; set; }
1214
}
13-
14-
public sealed class SeenLogSeenByActorDto
15-
{
16-
public Guid Id { get; set; }
17-
public string ActorName { get; set; } = null!;
18-
public string ActorId { get; set; } = null!;
19-
}

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Get/MappingProfile.cs

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ public MappingProfile()
1414
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src.TypeId))
1515
.ForMember(dest => dest.DeletedAt, opt => opt.MapFrom(src => src.Dialog.DeletedAt));
1616

17-
CreateMap<DialogTransmissionSenderActor, SenderActorDto>()
18-
.ForMember(dest => dest.ActorType, opt => opt.MapFrom(src => src.ActorTypeId));
1917

2018
CreateMap<List<DialogTransmissionContent>?, ContentDto?>()
2119
.ConvertUsing<TransmissionContentOutputConverter<ContentDto>>();

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Get/TransmissionDto.cs

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Digdir.Domain.Dialogporten.Application.Features.V1.Common.Content;
22
using Digdir.Domain.Dialogporten.Application.Features.V1.Common.Localizations;
3-
using Digdir.Domain.Dialogporten.Domain.Actors;
3+
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors;
44
using Digdir.Domain.Dialogporten.Domain.Attachments;
55
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Transmissions;
66

@@ -52,7 +52,7 @@ public sealed class TransmissionDto
5252
/// <summary>
5353
/// The sender actor information for the transmission.
5454
/// </summary>
55-
public SenderActorDto Sender { get; set; } = null!;
55+
public ActorDto Sender { get; set; } = null!;
5656

5757
/// <summary>
5858
/// The content of the transmission.
@@ -65,29 +65,6 @@ public sealed class TransmissionDto
6565
public List<AttachmentDto> Attachments { get; set; } = [];
6666
}
6767

68-
public sealed class SenderActorDto
69-
{
70-
/// <summary>
71-
/// The unique identifier for the sender actor in UUIDv7 format.
72-
/// </summary>
73-
public Guid Id { get; set; }
74-
75-
/// <summary>
76-
/// The type of the actor.
77-
/// </summary>
78-
public ActorType.Values ActorType { get; set; }
79-
80-
/// <summary>
81-
/// The name of the actor.
82-
/// </summary>
83-
public string ActorName { get; set; } = null!;
84-
85-
/// <summary>
86-
/// The identifier of the actor.
87-
/// </summary>
88-
public string ActorId { get; set; } = null!;
89-
}
90-
9168
public sealed class ContentDto
9269
{
9370
/// <summary>

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Search/MappingProfile.cs

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ public MappingProfile()
1414
.ForMember(dest => dest.Type, opt => opt.MapFrom(src => src.TypeId))
1515
.ForMember(dest => dest.DeletedAt, opt => opt.MapFrom(src => src.Dialog.DeletedAt));
1616

17-
CreateMap<DialogTransmissionSenderActor, SenderActorDto>()
18-
.ForMember(dest => dest.ActorType, opt => opt.MapFrom(src => src.ActorTypeId));
1917

2018
CreateMap<List<DialogTransmissionContent>?, ContentDto?>()
2119
.ConvertUsing<TransmissionContentOutputConverter<ContentDto>>();

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Search/TransmissionDto.cs

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Digdir.Domain.Dialogporten.Application.Features.V1.Common.Content;
22
using Digdir.Domain.Dialogporten.Application.Features.V1.Common.Localizations;
3-
using Digdir.Domain.Dialogporten.Domain.Actors;
3+
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors;
44
using Digdir.Domain.Dialogporten.Domain.Attachments;
55
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Transmissions;
66

@@ -52,7 +52,7 @@ public sealed class TransmissionDto
5252
/// <summary>
5353
/// The sender actor information for the transmission.
5454
/// </summary>
55-
public SenderActorDto Sender { get; set; } = null!;
55+
public ActorDto Sender { get; set; } = null!;
5656

5757
/// <summary>
5858
/// The content of the transmission.
@@ -65,29 +65,6 @@ public sealed class TransmissionDto
6565
public List<AttachmentDto> Attachments { get; set; } = [];
6666
}
6767

68-
public sealed class SenderActorDto
69-
{
70-
/// <summary>
71-
/// The unique identifier for the sender actor in UUIDv7 format.
72-
/// </summary>
73-
public Guid Id { get; set; }
74-
75-
/// <summary>
76-
/// The type of the actor.
77-
/// </summary>
78-
public ActorType.Values ActorType { get; set; }
79-
80-
/// <summary>
81-
/// The name of the actor.
82-
/// </summary>
83-
public string ActorName { get; set; } = null!;
84-
85-
/// <summary>
86-
/// The identifier of the actor.
87-
/// </summary>
88-
public string ActorId { get; set; } = null!;
89-
}
90-
9168
public sealed class ContentDto
9269
{
9370
/// <summary>

0 commit comments

Comments
 (0)