diff options
author | claiff <claiff@mail.ru> | 2022-09-21 15:50:34 +0300 |
---|---|---|
committer | claiff <claiff@mail.ru> | 2022-09-21 15:50:34 +0300 |
commit | 641c95dcf8c6585caaa6e79d4bec9b53fd666369 (patch) | |
tree | 3c7e38f17738c181437f482d05c66dde94f7c28a /src/file/mail.cpp | |
parent | 629929ebbe386277c25740bc0f4971aac38444d0 (diff) | |
parent | 6cfc7076808138be2ad5a2b05edd635b5948bf31 (diff) | |
download | obmc-sila-smtp-641c95dcf8c6585caaa6e79d4bec9b53fd666369.tar.xz |
Merge branch 'feature/checking'
Diffstat (limited to 'src/file/mail.cpp')
-rw-r--r-- | src/file/mail.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/file/mail.cpp b/src/file/mail.cpp index 5452136..2b1ff14 100644 --- a/src/file/mail.cpp +++ b/src/file/mail.cpp @@ -1,12 +1,13 @@ #include <fstream> #include "mail.hpp" -#include "managment/logger.hpp" +#include "management/logger.hpp" namespace smtp::file { - Mail::Mail( std::string const& path_file ) + Mail::Mail( std::string const& path_file, checker::RegistratorMails const& registrator_errors ) : mPathFile( path_file ) + , mRegistratorErrors( registrator_errors ) { } @@ -23,11 +24,10 @@ namespace smtp::file while ( std::getline( mail_file, line ) ) { - auto parsed_data = GetMailFromLine( line ); - if( parsed_data ) - { - result.push_back( *parsed_data ); - } + if( mRegistratorErrors.Check( line ) ) + { + result.push_back( line ); + } } mail_file.close(); return result; @@ -41,23 +41,14 @@ namespace smtp::file manage::Logger::LogError( "Unable to open file to write " + mPathFile ); return false; } - for( const auto& pair : data ) + for( const auto& mail : data ) { - mail_file << pair << "\n"; + if( mRegistratorErrors.Check( mail ) ) + { + mail_file << mail << "\n"; + } } mail_file.close(); return true; } - - std::optional<std::string> Mail::GetMailFromLine( std::string const& line ) const - { - //TODO registrator if checking parsing - auto pos = line.find('@'); - if(pos == std::string::npos) - { - return {}; - } - return line; - } - } |