MCPcopy Create free account
hub / github.com/YACReader/yacreader / service

Method service

YACReaderLibrary/server/controllers/v2/synccontroller_v2.cpp:18–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void 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;

Callers

nothing calls this directly

Calls 6

splitMethod · 0.80
isEmptyMethod · 0.80
getIdFromUuidMethod · 0.80
writeMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected