X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fmysql.cpp;h=67fc49ecc65bae1122a196242c41a2380e194ac8;hb=aef2ba57f652658f3bebfa24e706c0083a56e6bf;hp=66c24427411664c1aceb23605e5679aa63520611;hpb=858fcca3a53da84a306f55d1811bf119bf8d862f;p=cassiopeia.git diff --git a/src/mysql.cpp b/src/mysql.cpp index 66c2442..67fc49e 100644 --- a/src/mysql.cpp +++ b/src/mysql.cpp @@ -155,7 +155,7 @@ std::shared_ptr MySQLJobProvider::fetchJob() { return job; } -std::string MySQLJobProvider::escape_string( const std::string & target ) { +std::string MySQLJobProvider::escape_string( const std::string& target ) { if( !conn ) { throw "Not connected!"; } @@ -243,3 +243,17 @@ std::shared_ptr MySQLJobProvider::fetchTBSCert( std::shared_ptr< return cert; } + +void MySQLJobProvider::writeBack( std::shared_ptr job, std::shared_ptr res ) { + if( !conn ) { + throw "Error while writing back"; + } + + std::string q = "UPDATE certs SET crt_name='" + this->escape_string( res->crt_name ) + "', serial='" + this->escape_string( std::to_string( res->serial ) ) + "' WHERE id='" + this->escape_string( job->id ) + "' LIMIT 1"; + + // TODO write more thingies back + + if( query( q ).first ) { + throw "Error while writing back"; + } +}