<commit_before>﻿using Bit.Core;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace Bit.Billing.Controllers
{
    [Route("apple")]
    public class AppleController : Controller
    {
        private readonly BillingSettings _billingSettings;
        private readonly ILogger<AppleController> _logger;

        public AppleController(
            IOptions<BillingSettings> billingSettings,
            ILogger<AppleController> logger)
        {
            _billingSettings = billingSettings?.Value;
            _logger = logger;
        }

        [HttpPost("iap")]
        public async Task<IActionResult> PostIap()
        {
            if(HttpContext?.Request?.Query == null)
            {
                return new BadRequestResult();
            }

            var key = HttpContext.Request.Query.ContainsKey("key") ?
                HttpContext.Request.Query["key"].ToString() : null;
            if(key != _billingSettings.AppleWebhookKey)
            {
                return new BadRequestResult();
            }

            string body = null;
            using(var reader = new StreamReader(HttpContext.Request.Body, Encoding.UTF8))
            {
                body = await reader.ReadToEndAsync();
            }

            if(string.IsNullOrWhiteSpace(body))
            {
                return new BadRequestResult();
            }

            try
            {
                var json = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(body), Formatting.Indented);
                _logger.LogInformation("Apple IAP Notification:\n\n" + Constants.BypassFiltersEventId, json);
                return new OkResult();
            }
            catch(Exception e)
            {
                _logger.LogError(e, "Error processing IAP status notification.");
                return new BadRequestResult();
            }
        }
    }
}<commit_msg>fix info logger for apple iap<commit_after>﻿using Bit.Core;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace Bit.Billing.Controllers
{
    [Route("apple")]
    public class AppleController : Controller
    {
        private readonly BillingSettings _billingSettings;
        private readonly ILogger<AppleController> _logger;

        public AppleController(
            IOptions<BillingSettings> billingSettings,
            ILogger<AppleController> logger)
        {
            _billingSettings = billingSettings?.Value;
            _logger = logger;
        }

        [HttpPost("iap")]
        public async Task<IActionResult> PostIap()
        {
            if(HttpContext?.Request?.Query == null)
            {
                return new BadRequestResult();
            }

            var key = HttpContext.Request.Query.ContainsKey("key") ?
                HttpContext.Request.Query["key"].ToString() : null;
            if(key != _billingSettings.AppleWebhookKey)
            {
                return new BadRequestResult();
            }

            string body = null;
            using(var reader = new StreamReader(HttpContext.Request.Body, Encoding.UTF8))
            {
                body = await reader.ReadToEndAsync();
            }

            if(string.IsNullOrWhiteSpace(body))
            {
                return new BadRequestResult();
            }

            try
            {
                var json = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(body), Formatting.Indented);
                _logger.LogInformation(Constants.BypassFiltersEventId, "Apple IAP Notification:\n\n{0}", json);
                return new OkResult();
            }
            catch(Exception e)
            {
                _logger.LogError(e, "Error processing IAP status notification.");
                return new BadRequestResult();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.0891812865497076, 'fraction_numerical': 0.0007309941520467836, 'mean_word_length': 1.8606271777003485, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '241046', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1006, 'n_words': 209}