Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abl 490 limit the maximum number of message recipients #1027

Closed
3 changes: 2 additions & 1 deletion .ci/appsettings.override.postgres.docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
},
"Messages": {
"Application": {
"DidDomainName": "localhost"
"DidDomainName": "localhost",
"MaxNumberOfMessageRecipients": 5
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
3 changes: 2 additions & 1 deletion .ci/appsettings.override.postgres.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
},
"Messages": {
"Application": {
"DidDomainName": "localhost"
"DidDomainName": "localhost",
"MaxNumberOfMessageRecipients": 5
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
3 changes: 2 additions & 1 deletion .ci/appsettings.override.sqlserver.docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
},
"Messages": {
"Application": {
"DidDomainName": "localhost"
"DidDomainName": "localhost",
"MaxNumberOfMessageRecipients": 5
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
3 changes: 2 additions & 1 deletion .ci/appsettings.override.sqlserver.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
},
"Messages": {
"Application": {
"DidDomainName": "localhost"
"DidDomainName": "localhost",
"MaxNumberOfMessageRecipients": 5
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
3 changes: 2 additions & 1 deletion Applications/ConsumerApi/src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"Pagination": {
"DefaultPageSize": 50,
"MaxPageSize": 200
}
},
"MaxNumberOfMessageRecipients": 1
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
},
"Messages": {
"Application": {
"DidDomainName": "localhost"
"DidDomainName": "localhost",
"MaxNumberOfMessageRecipients": 5
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class ApplicationOptions
[MinLength(3)]
[MaxLength(45)]
public string DidDomainName { get; set; } = null!;

[Required]
public int MaxNumberOfMessageRecipients { get; set; }
}

public class PaginationOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
using Backbone.Modules.Messages.Domain.Ids;
using Backbone.Tooling.Extensions;
using FluentValidation;
using Microsoft.Extensions.Options;

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

public class Validator : AbstractValidator<SendMessageCommand>
{
public Validator()
public Validator(IOptions<ApplicationOptions> options)
{
RuleFor(m => m.Recipients)
.DetailedNotNull()
Expand All @@ -21,7 +22,8 @@ public Validator()
.SetValidator(new SendMessageCommandRecipientInformationValidator()));

RuleFor(m => m.Recipients.Count)
.InclusiveBetween(1, 50).WithErrorCode(GenericApplicationErrors.Validation.InvalidPropertyValue().Code);
.LessThanOrEqualTo(options.Value.MaxNumberOfMessageRecipients)
.WithErrorCode(GenericApplicationErrors.Validation.InvalidPropertyValue().Code);

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

Expand Down
Loading