Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
energinet-ajw committed May 30, 2023
1 parent 765ea20 commit c7d7159
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ protected MarketActorIdentity(string id, ActorNumber? number, IEnumerable<Market

public string Id { get; }

/// <summary>
/// Actor number.
/// TODO AJW: Remove nullable.
/// </summary>
public ActorNumber? Number { get; }

public bool HasRole(string role)
Expand Down
10 changes: 1 addition & 9 deletions source/CimMessageAdapter/Messages/MessageReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ public async Task<Result> ReceiveAsync<TMarketActivityRecordType, TMarketTransac
var messageHeader = messageParserResult.IncomingMarketDocument?.Header;
var marketDocument = messageParserResult.IncomingMarketDocument;

if (InvalidMessageHeader(messageHeader))
if (messageHeader is null)
{
return Result.Failure(messageParserResult.Errors.ToArray());
}

ArgumentNullException.ThrowIfNull(messageHeader);
ArgumentNullException.ThrowIfNull(marketDocument);

await AuthorizeSenderAsync(messageHeader).ConfigureAwait(false);
Expand Down Expand Up @@ -93,11 +92,6 @@ public async Task<Result> ReceiveAsync<TMarketActivityRecordType, TMarketTransac
return Result.Succeeded();
}

private static bool InvalidMessageHeader(MessageHeader? header)
{
return header is null;
}

private Task<bool> CheckTransactionIdAsync(string transactionId, CancellationToken cancellationToken)
{
if (transactionId == null) throw new ArgumentNullException(nameof(transactionId));
Expand Down Expand Up @@ -132,14 +126,12 @@ private async Task CheckMessageIdAsync(string messageId, CancellationToken cance

private async Task AuthorizeSenderAsync(MessageHeader messageHeader)
{
if (messageHeader == null) throw new ArgumentNullException(nameof(messageHeader));
var result = await _senderAuthorizer.AuthorizeAsync(messageHeader.SenderId, messageHeader.SenderRole).ConfigureAwait(false);
_errors.AddRange(result.Errors);
}

private async Task VerifyReceiverAsync(MessageHeader messageHeader)
{
if (messageHeader == null) throw new ArgumentNullException(nameof(messageHeader));
var receiverVerification = await ReceiverVerification.VerifyAsync(messageHeader.ReceiverId, messageHeader.ReceiverRole).ConfigureAwait(false);
_errors.AddRange(receiverVerification.Errors);
}
Expand Down

0 comments on commit c7d7159

Please sign in to comment.