mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 02:54:46 -04:00
Separate v1 and v2 server api classes and execution path.
This commit is contained in:
64
YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp
Normal file
64
YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "synccontroller_v2.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
#include <QUrl>
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "db_helper.h"
|
||||
|
||||
SyncControllerV2::SyncControllerV2()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SyncControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
|
||||
QLOG_TRACE() << "POST DATA: " << postData;
|
||||
|
||||
if(postData.length()>0) {
|
||||
QList<QString> data = postData.split("\n");
|
||||
|
||||
qulonglong libraryId;
|
||||
qulonglong comicId;
|
||||
int currentPage;
|
||||
int currentRating;
|
||||
QString hash;
|
||||
foreach(QString comicInfo, data)
|
||||
{
|
||||
QList<QString> comicInfoProgress = comicInfo.split("\t");
|
||||
|
||||
if(comicInfoProgress.length() == 4 || comicInfoProgress.length() == 5)
|
||||
{
|
||||
libraryId = comicInfoProgress.at(0).toULongLong();
|
||||
comicId = comicInfoProgress.at(1).toULongLong();
|
||||
hash = comicInfoProgress.at(2);
|
||||
currentPage = comicInfoProgress.at(3).toInt();
|
||||
|
||||
ComicInfo info;
|
||||
info.currentPage = currentPage;
|
||||
info.hash = hash; //TODO remove the hash check and add UUIDs for libraries
|
||||
info.id = comicId;
|
||||
|
||||
//Client 2.1+ version
|
||||
if(comicInfoProgress.length() > 4)
|
||||
{
|
||||
currentRating = comicInfoProgress.at(4).toInt();
|
||||
info.rating = currentRating;
|
||||
}
|
||||
|
||||
DBHelper::updateFromRemoteClient(libraryId,info);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(412,"No comic info received");
|
||||
response.write("",true);
|
||||
return;
|
||||
}
|
||||
|
||||
response.write("OK",true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user