diff options
Diffstat (limited to 'src/file/mail.cpp')
-rw-r--r-- | src/file/mail.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/file/mail.cpp b/src/file/mail.cpp index 5452136..c728edc 100644 --- a/src/file/mail.cpp +++ b/src/file/mail.cpp @@ -5,8 +5,9 @@ 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; - } - } |