public async Task <ResponseDeliverTx> DeliverTx(TransactionToken transactionToken, object data, RequestDeliverTx request, ServerCallContext context) { if (!(data is DenyTransferRequest payload)) { return(ResponseHelper.Deliver.NoPayload()); } var callNumber = await _callNumberRepository.Get(payload.PhoneNumber); if (callNumber == null) { return(ResponseHelper.Deliver.Create(CodeType.UnknownCallNumber, "Unknown call number.")); } if (!IsVerifiedCaller(transactionToken, callNumber.Owner)) { return(ResponseHelper.Deliver.Unauthorized()); } callNumber.TransferRequestedTo = null; callNumber.TransferRequestStarted = null; await _callNumberRepository.Update(callNumber); return(ResponseHelper.Deliver.Ok()); }
public async Task <ResponseDeliverTx> DeliverTx(TransactionToken transactionToken, RequestTransfer payload, RequestDeliverTx request, ServerCallContext context) { if (!IsVerifiedCaller(transactionToken, payload.NewOwner)) { return(ResponseHelper.Deliver.Unauthorized()); } _logger.LogInformation("Received valid CheckTx request"); var callNumber = await _callNumberRepository.Get(payload.PhoneNumber); callNumber.TransferRequestStarted = payload.TransferStarted; callNumber.TransferRequestedTo = payload.NewOwner; await _callNumberRepository.Update(callNumber); _logger.LogInformation($"DeliverTx Result: ok, transfer started: {callNumber.TransferRequestStarted}, to: {callNumber.TransferRequestedTo}"); return(ResponseHelper.Deliver.Ok()); }