blob: 7a8aa42885e60d63414a70295f20ac47ba0c545c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include "mail.hpp"
#include "checker/errors/mail/empty.hpp"
#include "checker/errors/mail/at_sign.hpp"
#include "file/mail/file_decorator.hpp"
#include "file/mail/checker_decorator.hpp"
#include "file/mail/sort_decorator.hpp"
#include "file/errors/not_create.hpp"
namespace smtp::manage::builder
{
smtp::manage::Mail Mail::Build() const
{
return smtp::manage::Mail{BuildFileManipulator()};
}
file::mail::types::IFileManipulatorPtr Mail::BuildFileManipulator() const
{
static const std::string PATH = {"/var/lib/smtp/mails.txt"};
auto result = std::make_shared<file::mail::SortDecorator>() ;
result->Apply(std::make_shared<file::mail::CheckerDecorator>( BuildSettingsErrorRegistrator() ))
.Apply(std::make_shared<file::mail::FileDecorator>( PATH, BuildFileErrorRegistrator(PATH) ));
return result;
}
file::errors::Registrator Mail::BuildFileErrorRegistrator( std::string const& path ) const
{
file::errors::Registrator result;
auto not_created_file_error = std::make_shared<file::errors::NotCreatedFile>(path);
result.Add(not_created_file_error, ENOENT);
return result;
}
checker::RegistratorMails Mail::BuildSettingsErrorRegistrator() const
{
checker::RegistratorMails result;
result.Add( std::make_shared < checker::errors::mail::Empty >());
result.Add( std::make_shared < checker::errors::mail::AtSign >());
return result;
}
}
|