| 16 | } |
| 17 | |
| 18 | void SyncControllerV2::service(HttpRequest &request, HttpResponse &response) |
| 19 | { |
| 20 | response.setHeader("Content-Type", "text/plain; charset=utf-8"); |
| 21 | |
| 22 | QString postData = QString::fromUtf8(request.getBody()); |
| 23 | |
| 24 | QLOG_TRACE() << "POST DATA: " << postData; |
| 25 | |
| 26 | if (postData.length() > 0) { |
| 27 | const auto data = postData.split("\n"); |
| 28 | |
| 29 | qulonglong libraryId; |
| 30 | qulonglong comicId; |
| 31 | int currentPage; |
| 32 | int currentRating; |
| 33 | unsigned long long lastTimeOpened; |
| 34 | QString hash; |
| 35 | QMap<qulonglong, QList<ComicInfo>> comics; |
| 36 | QList<ComicInfo> comicsWithNoLibrary; |
| 37 | |
| 38 | const auto libraries = DBHelper::getLibraries(); |
| 39 | |
| 40 | bool clientSendsHasBeenOpened = false; |
| 41 | bool clientSendsImageFilters = false; |
| 42 | |
| 43 | for (const auto &comicInfo : data) { |
| 44 | if (comicInfo.isEmpty()) { |
| 45 | continue; |
| 46 | } |
| 47 | |
| 48 | const auto comicInfoProgress = comicInfo.split("\t"); |
| 49 | |
| 50 | if (comicInfoProgress.isEmpty()) { |
| 51 | continue; |
| 52 | } |
| 53 | |
| 54 | if (comicInfoProgress.at(0) == "u") { // Android |
| 55 | clientSendsHasBeenOpened = true; |
| 56 | |
| 57 | if (comicInfoProgress.length() < 9) { |
| 58 | continue; |
| 59 | } |
| 60 | |
| 61 | auto libraryUuid = QUuid(comicInfoProgress.at(1)); |
| 62 | |
| 63 | if (libraryUuid.isNull()) { |
| 64 | continue; |
| 65 | } |
| 66 | |
| 67 | auto libraryId = libraries.getIdFromUuid(libraryUuid); |
| 68 | if (libraryId == -1) { |
| 69 | continue; |
| 70 | } |
| 71 | comicId = comicInfoProgress.at(2).toULongLong(); |
| 72 | hash = comicInfoProgress.at(3); |
| 73 | currentPage = comicInfoProgress.at(4).toInt(); |
| 74 | |
| 75 | ComicInfo info; |
nothing calls this directly
no test coverage detected