Beispiel #1
0
        public IActionResult IncomingSMS([FromForm] SMS sms)
        {
            _logger.Information($"Processing incoming SMSeagle message: '{sms.Sender}' '{sms.Text}' '{sms.ApiKey}'");

            var tenantId = _mapper.GetTenantFor(sms.ApiKey);

            if (tenantId == TenantId.Unknown)
            {
                return(StatusCode(403));
            }

            _contextManager.CurrentFor(tenantId);


            var command = new ReceiveMessageFromSMSGateway {
                Id          = Guid.NewGuid(),
                Sender      = sms.Sender,
                Text        = sms.Text,
                Received    = DateTimeOffset.ParseExact(sms.Timestamp, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal),
                ApiKey      = sms.ApiKey,
                GatewayId   = sms.MsgID,
                OID         = sms.OID,
                ModemNumber = sms.ModemNo,
            };

            var result = _commandCoordinator.Handle(command);

            if (!result.Success)
            {
                throw new ReceiveMessageFromSMSGatewayFailed(command, result);
            }

            return(Ok());
        }
Beispiel #2
0
 public ReceiveMessageFromSMSGatewayFailed(ReceiveMessageFromSMSGateway command, CommandResult result)
     : base($"Receiving message '{command.Text}' from '{command.Sender}' failed. Validation [{String.Join(',', result.ValidationResults.Select(_ => _.ErrorMessage))}], Security [{String.Join(',', result.SecurityMessages)}]", result.Exception)
 {
 }
Beispiel #3
0
 public void Handle(ReceiveMessageFromSMSGateway cmd)
 {
     _aggregateRootRepoForMessage.Get((Guid)cmd.Id).ReceivedMessage(cmd.Id, cmd.Sender, cmd.Text, cmd.Received);
 }