Skip to content

Commit

Permalink
Merge pull request #278 from Energinet-DataHub/batrman/beating_a_dead…
Browse files Browse the repository at this point in the history
…_horse

refac: removed unneeded code
  • Loading branch information
MadsDue authored May 30, 2023
2 parents 765ea20 + c7d7159 commit 668e990
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 668e990

Please sign in to comment.