summaryrefslogtreecommitdiff
path: root/src/file/mail.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/file/mail.cpp')
-rw-r--r--src/file/mail.cpp33
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;
- }
-
}