Ejemplo n.º 1
0
        public async Task OfferStatusReturnsError()
        {
            _offerMinmalInfo.StatusCode = 6;
            _offerMinmalInfo.Error      = new OfferStatusError
            {
                Message = "Error"
            };

            var offerManager = new OfferManager(
                _fakedSteamHubConnection,
                _fakedOfferService,
                new RpcSteamListener(_loggerDummy),
                _loggerDummy,
                _fakedGrpcServiceFactory,
                _fakedUserService,
                _fakedRepoServiceFactory
                );

            await offerManager.HandleOffer(_offerMinmalInfo);

            A.CallTo(() => _fakedSteamHubConnection.SendErrorMessageRelatedToOurApi(A <string> ._, A <string> ._)).MustHaveHappened();
            A.CallTo(() => _fakedRakeItemRepo.SetAsSold(A <List <string> > ._)).MustNotHaveHappened();
            A.CallTo(() => _fakedSteamHubConnection.SendOfferStatusToUser(A <OfferStatusRequest> ._, A <string> ._)).MustNotHaveHappened();
        }
Ejemplo n.º 2
0
        public async Task HandleOffer(OfferStatusRequest offer)
        {
            try
            {
                if (offer.DataCase == OfferStatusRequest.DataOneofCase.OfferSend && offer.OfferSend.SteamOffer.Message == "sendSellRakeOffer")
                {
                    var itemsSuccessfulySentToBot = offer.OfferSend.SteamOffer.ItemsToGive;
                    var assetIds = itemsSuccessfulySentToBot.Select(item => item.AssetId).ToList();

                    await _rakeItemRepoService.SetAsSold(assetIds);

                    return;
                }
            }
            catch (System.Exception e)
            {
                _logger.Error(offer.SteamId, null, e, new Dictionary <string, object>
                {
                    { "Offer", offer }
                });
                return;
            }

            if (offer.DataCase == OfferStatusRequest.DataOneofCase.Error)
            {
                await _steamHubConnections.SendErrorMessageRelatedToOurApi("Internal error processing offer, please try again later!", offer.SteamId);

                return;
            }

            FixSteamItemsBadNaming(offer);

            switch (offer.StatusCode)
            {
            case 5:
                await HandleDeposit(offer);

                break;

            case 6:
                await HandleWithdrawal(offer);

                break;

            case 14:
            case 16:
            case 19:
            case 20:
                await RemoveCanceledOfferFromOfferTransaction(offer);

                break;
            }

            var request = new OfferStatusRequest
            {
                StatusCode = offer.StatusCode,
                SteamId    = offer.SteamId,
                OfferSend  = offer.OfferSend
            };
            await _steamHubConnections.SendOfferStatusToUser(request, offer.SteamId);
        }