<commit_before>﻿using Collectively.Api.Commands;
using Collectively.Api.Queries;
using Collectively.Api.Storages;
using Collectively.Api.Validation;
using Collectively.Common.Types;
using Collectively.Common.Extensions;
using Collectively.Services.Storage.Models.Operations;
using Nancy.Security;

namespace Collectively.Api.Modules
{
    public class OperationModule : ModuleBase
    {
        public OperationModule(ICommandDispatcher commandDispatcher,
            IValidatorResolver validatorResolver,
            IOperationStorage operationStorage)
            : base(commandDispatcher, validatorResolver, modulePath: "operations")
        {
            Get("{requestId}", args => Fetch<GetOperation, Operation>
            (async x =>
            {
                var operation = await operationStorage.GetAsync(x.RequestId);
                if (operation.HasNoValue || operation.Value.UserId.Empty())
                {
                    return operation;
                }
                this.RequiresAuthentication();

                return operation.Value.UserId == CurrentUserId
                    ? operation
                    : new Maybe<Operation>();
            }).HandleAsync());
        }
    }
}<commit_msg>Fixed IoC for operation provider<commit_after>﻿using Collectively.Api.Commands;
using Collectively.Api.Queries;
using Collectively.Api.Storages;
using Collectively.Api.Validation;
using Collectively.Common.Types;
using Collectively.Common.Extensions;
using Collectively.Services.Storage.Models.Operations;
using Nancy.Security;
using Collectively.Api.Services;
using Nancy;

namespace Collectively.Api.Modules
{
    public class OperationModule : ModuleBase
    {
        public OperationModule(ICommandDispatcher commandDispatcher,
            IValidatorResolver validatorResolver,
            IOperationProvider operationProvider)
            : base(commandDispatcher, validatorResolver, modulePath: "operations")
        {
            Get("{requestId}", args => Fetch<GetOperation, Operation>
            (async x =>
            {
                var operation = await operationProvider.GetAsync(x.RequestId);
                if (operation == null)
                {
                    return new Maybe<Operation>();
                }
                if (operation.UserId.Empty())
                {
                    return operation;
                }
                this.RequiresAuthentication();

                return operation.UserId == CurrentUserId
                    ? operation
                    : new Maybe<Operation>();
            }).HandleAsync());
        }
    }
}
{'fraction_non_alphanumeric': 0.08466819221967964, 'fraction_numerical': 0.0, 'mean_word_length': 2.111506524317912, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, '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': '3306258', 'n_tokens_mistral': 611, 'n_tokens_neox': 595, 'n_words': 125}