Skip to content

Commit 0421851

Browse files
tnotheisdevx247mergify[bot]
authored
Allow only one message recipient and add possibility to configure more than one recipient (#1033)
* feat: added MaxNumberOfMessageRecipients * fix: integration-test appsettings * fix: updated Validator * chore: removed custom validation name --------- Co-authored-by: Eric Brunner <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 6d4a4da commit 0421851

File tree

8 files changed

+19
-8
lines changed

8 files changed

+19
-8
lines changed

.ci/appsettings.override.postgres.docker.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
},
8080
"Messages": {
8181
"Application": {
82-
"DidDomainName": "localhost"
82+
"DidDomainName": "localhost",
83+
"MaxNumberOfMessageRecipients": 5
8384
},
8485
"Infrastructure": {
8586
"SqlDatabase": {

.ci/appsettings.override.postgres.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
},
8080
"Messages": {
8181
"Application": {
82-
"DidDomainName": "localhost"
82+
"DidDomainName": "localhost",
83+
"MaxNumberOfMessageRecipients": 5
8384
},
8485
"Infrastructure": {
8586
"SqlDatabase": {

.ci/appsettings.override.sqlserver.docker.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
},
8080
"Messages": {
8181
"Application": {
82-
"DidDomainName": "localhost"
82+
"DidDomainName": "localhost",
83+
"MaxNumberOfMessageRecipients": 5
8384
},
8485
"Infrastructure": {
8586
"SqlDatabase": {

.ci/appsettings.override.sqlserver.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
},
8080
"Messages": {
8181
"Application": {
82-
"DidDomainName": "localhost"
82+
"DidDomainName": "localhost",
83+
"MaxNumberOfMessageRecipients": 5
8384
},
8485
"Infrastructure": {
8586
"SqlDatabase": {

Applications/ConsumerApi/src/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
"Pagination": {
8585
"DefaultPageSize": 50,
8686
"MaxPageSize": 200
87-
}
87+
},
88+
"MaxNumberOfMessageRecipients": 1
8889
},
8990
"Infrastructure": {
9091
"SqlDatabase": {

Applications/ConsumerApi/test/ConsumerApi.Tests.Integration/api.appsettings.local.override.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
},
5151
"Messages": {
5252
"Application": {
53-
"DidDomainName": "localhost"
53+
"DidDomainName": "localhost",
54+
"MaxNumberOfMessageRecipients": 5
5455
},
5556
"Infrastructure": {
5657
"SqlDatabase": {

Modules/Messages/src/Messages.Application/ApplicationOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public class ApplicationOptions
1414
[MinLength(3)]
1515
[MaxLength(45)]
1616
public string DidDomainName { get; set; } = null!;
17+
18+
[Required]
19+
public int MaxNumberOfMessageRecipients { get; set; }
1720
}
1821

1922
public class PaginationOptions

Modules/Messages/src/Messages.Application/Messages/Commands/SendMessage/Validator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
using Backbone.Modules.Messages.Domain.Ids;
66
using Backbone.Tooling.Extensions;
77
using FluentValidation;
8+
using Microsoft.Extensions.Options;
89

910
namespace Backbone.Modules.Messages.Application.Messages.Commands.SendMessage;
1011

1112
public class Validator : AbstractValidator<SendMessageCommand>
1213
{
13-
public Validator()
14+
public Validator(IOptions<ApplicationOptions> options)
1415
{
1516
RuleFor(m => m.Recipients)
1617
.DetailedNotNull()
@@ -21,7 +22,8 @@ public Validator()
2122
.SetValidator(new SendMessageCommandRecipientInformationValidator()));
2223

2324
RuleFor(m => m.Recipients.Count)
24-
.InclusiveBetween(1, 50).WithErrorCode(GenericApplicationErrors.Validation.InvalidPropertyValue().Code);
25+
.LessThanOrEqualTo(options.Value.MaxNumberOfMessageRecipients)
26+
.WithErrorCode(GenericApplicationErrors.Validation.InvalidPropertyValue().Code);
2527

2628
RuleFor(m => m.Body).DetailedNotNull().NumberOfBytes(1, 10.Mebibytes());
2729

0 commit comments

Comments
 (0)