<commit_before>﻿using System;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Serilog;
using Lime.Messaging.Contents;

namespace Take.Blip.Builder.Actions.Redirect
{
    public class RedirectAction : IAction
    {
        private readonly IRedirectManager _redirectManager;
        private readonly ILogger _logger;

        public RedirectAction(IRedirectManager redirectManager, ILogger logger)
        {
            _redirectManager = redirectManager;
            _logger = logger;
        }

        public string Type => nameof(Redirect);

        public Task ExecuteAsync(IContext context, JObject settings, CancellationToken cancellationToken)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (settings == null) throw new ArgumentNullException(nameof(settings));

            var redirect = settings.ToObject<Redirect>(LimeSerializerContainer.Serializer);
            context.Input.Message.Metadata.TryGetValue("REDIRECT_TEST_LOG", out var metadataRedirectAddress);
            if (redirect.Address == metadataRedirectAddress) 
            {
                _logger.Warning($"#REDIRECT_LOG# ({context.Input.Message}) - ({redirect.Address}) - ({redirect.Context})");
            }
            return _redirectManager.RedirectUserAsync(context, redirect, cancellationToken);
        }
    }
}<commit_msg>fixing comments<commit_after>﻿using System;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Serilog;

namespace Take.Blip.Builder.Actions.Redirect
{
    public class RedirectAction : IAction
    {
        private readonly IRedirectManager _redirectManager;
        private readonly ILogger _logger;

        public RedirectAction(IRedirectManager redirectManager, ILogger logger)
        {
            _redirectManager = redirectManager;
            _logger = logger;
        }

        public string Type => nameof(Redirect);

        public Task ExecuteAsync(IContext context, JObject settings, CancellationToken cancellationToken)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (settings == null) throw new ArgumentNullException(nameof(settings));

            var redirect = settings.ToObject<Lime.Messaging.Contents.Redirect>(LimeSerializerContainer.Serializer);
            context.Input.Message.Metadata.TryGetValue("REDIRECT_TEST_LOG", out var metadataRedirectAddress);
            if (redirect.Address == metadataRedirectAddress) 
            {
                _logger.Warning($"#REDIRECT_LOG# ({context.Input.Message}) - ({redirect.Address}) - ({redirect.Context})");
            }
            return _redirectManager.RedirectUserAsync(context, redirect, cancellationToken);
        }
    }
}
{'fraction_non_alphanumeric': 0.08822483102098898, 'fraction_numerical': 0.0, 'mean_word_length': 3.034433285509326, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2272328', 'n_tokens_mistral': 687, 'n_tokens_neox': 691, 'n_words': 153}