mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Some checks failed
Build / Initialization (push) Has been cancelled
Build / Code Format Validation (push) Has been cancelled
Build / Linux (Qt6) (push) Has been cancelled
Build / Linux (Qt6 + 7zip) (push) Has been cancelled
Build / macOS (Qt6 Universal) (push) Has been cancelled
Build / Windows x64 (Qt6) (push) Has been cancelled
Build / Windows ARM64 (Qt6) (push) Has been cancelled
Build / Docker amd64 Image (push) Has been cancelled
Build / Docker arm64 Image (push) Has been cancelled
Build / Publish Dev Builds (push) Has been cancelled
Build / Publish Release (push) Has been cancelled
Build / Publish YACReader10 Pre-release Builds (push) Has been cancelled
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#include "readinglistcontentcontroller_v2.h"
|
|
|
|
#include "comic_db.h"
|
|
#include "db_helper.h"
|
|
#include "yacreader_libraries.h"
|
|
#include "yacreader_server_data_helper.h"
|
|
|
|
using stefanfrings::HttpRequest;
|
|
using stefanfrings::HttpResponse;
|
|
|
|
ReadingListContentControllerV2::ReadingListContentControllerV2()
|
|
{
|
|
}
|
|
|
|
void ReadingListContentControllerV2::service(HttpRequest &request, HttpResponse &response)
|
|
{
|
|
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
|
|
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
|
QStringList pathElements = path.split('/');
|
|
int libraryId = pathElements.at(3).toInt();
|
|
qulonglong readingListId = pathElements.at(5).toULongLong();
|
|
|
|
serviceContent(libraryId, readingListId, response);
|
|
|
|
response.write("", true);
|
|
}
|
|
|
|
void ReadingListContentControllerV2::serviceContent(const int &library, const qulonglong &readingListId, HttpResponse &response)
|
|
{
|
|
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(library);
|
|
|
|
QList<ComicDB> comics = DBHelper::getReadingListFullContent(library, readingListId);
|
|
|
|
QJsonArray items;
|
|
|
|
for (const ComicDB &comic : comics) {
|
|
items.append(YACReaderServerDataHelper::comicToJSON(library, libraryUuid, comic));
|
|
}
|
|
|
|
QJsonDocument output(items);
|
|
|
|
response.write(output.toJson(QJsonDocument::Compact));
|
|
}
|