mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 02:54:46 -04:00
Add controllers to provide comics information from reading lists and labels
This commit is contained in:
@ -32,10 +32,12 @@
|
||||
#include "controllers/v2/foldercontentcontroller_v2.h"
|
||||
#include "controllers/v2/tagscontroller_v2.h"
|
||||
#include "controllers/v2/tagcontentcontroller_v2.h"
|
||||
#include "controllers/v2/taginfocontroller_v2.h"
|
||||
#include "controllers/v2/favoritescontroller_v2.h"
|
||||
#include "controllers/v2/readingcomicscontroller_v2.h"
|
||||
#include "controllers/v2/readinglistscontroller_v2.h"
|
||||
#include "controllers/v2/readinglistcontentcontroller_v2.h"
|
||||
#include "controllers/v2/readinglistinfocontroller_v2.h"
|
||||
#include "controllers/v2/comicfullinfocontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
@ -44,16 +46,16 @@
|
||||
#include "yacreader_http_session.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
QMutex RequestMapper::mutex;
|
||||
|
||||
|
||||
QMutex RequestMapper::mutex;
|
||||
|
||||
|
||||
RequestMapper::RequestMapper(QObject* parent)
|
||||
:HttpRequestHandler(parent) {}
|
||||
|
||||
void RequestMapper::loadSessionV1(HttpRequest & request, HttpResponse& response)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
HttpSession session=Static::sessionStore->getSession(request,response);
|
||||
if(session.contains("ySession")) //session is already alive check if it is needed to update comics
|
||||
@ -117,31 +119,31 @@ void RequestMapper::loadSessionV1(HttpRequest & request, HttpResponse& response)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void RequestMapper::loadSessionV2(HttpRequest & request, HttpResponse& response)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
QByteArray token = request.getHeader("x-request-id");
|
||||
|
||||
if (token.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
YACReaderHttpSession *yRecoveredSession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(token);
|
||||
|
||||
if(yRecoveredSession == nullptr) //session is already alive check if it is needed to update comics
|
||||
{
|
||||
YACReaderHttpSession *ySession = new YACReaderHttpSession(this);
|
||||
|
||||
Static::yacreaderSessionStore->addYACReaderHttpSession(token, ySession);
|
||||
}
|
||||
}
|
||||
|
||||
void RequestMapper::loadSessionV2(HttpRequest & request, HttpResponse& response)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
QByteArray token = request.getHeader("x-request-id");
|
||||
|
||||
if (token.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
YACReaderHttpSession *yRecoveredSession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(token);
|
||||
|
||||
if(yRecoveredSession == nullptr) //session is already alive check if it is needed to update comics
|
||||
{
|
||||
YACReaderHttpSession *ySession = new YACReaderHttpSession(this);
|
||||
|
||||
Static::yacreaderSessionStore->addYACReaderHttpSession(token, ySession);
|
||||
}
|
||||
}
|
||||
|
||||
void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
QByteArray path=request.getPath();
|
||||
|
||||
QByteArray path=request.getPath();
|
||||
|
||||
QLOG_TRACE() << "RequestMapper: path=" << path.data();
|
||||
QLOG_TRACE() << "X-Request-Id: " << request.getHeader("x-request-id");
|
||||
|
||||
@ -260,8 +262,10 @@ void RequestMapper::serviceV2(HttpRequest& request, HttpResponse& response)
|
||||
QRegExp reading("/v2/library/.+/reading/?");
|
||||
QRegExp tags("/v2/library/.+/tags/?");
|
||||
QRegExp tagContent("/v2/library/.+/tag/[0-9]+/content/?");
|
||||
QRegExp tagInfo("/v2/library/.+/tag/[0-9]+/info/?");
|
||||
QRegExp readingLists("/v2/library/.+/reading_lists/?");
|
||||
QRegExp readingListContent("/v2/library/.+/reading_list/[0-9]+/content/?");
|
||||
QRegExp readingListInfo("/v2/library/.+/reading_list/[0-9]+/info/?");
|
||||
|
||||
QRegExp sync("/v2/sync");
|
||||
|
||||
@ -345,6 +349,14 @@ void RequestMapper::serviceV2(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
ReadingListContentControllerV2().service(request, response);
|
||||
}
|
||||
else if(readingListInfo.exactMatch(path))
|
||||
{
|
||||
ReadingListInfoControllerV2().service(request, response);
|
||||
}
|
||||
else if(tagInfo.exactMatch(path))
|
||||
{
|
||||
TagInfoControllerV2().service(request, response);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user