This commit is contained in:
Martin Rotter 2023-12-11 10:59:24 +01:00
parent 6b9041a110
commit d34c2d5792
3 changed files with 16 additions and 8 deletions

View File

@ -168,6 +168,15 @@ QJsonObject Message::toJson() const {
QJsonObject obj;
obj.insert(QSL("contents"), m_contents);
obj.insert(QSL("is_read"), m_isRead);
obj.insert(QSL("is_important"), m_isImportant);
obj.insert(QSL("title"), m_title);
obj.insert(QSL("date_created"), m_created.toMSecsSinceEpoch());
obj.insert(QSL("author"), m_author);
obj.insert(QSL("url"), m_url);
obj.insert(QSL("id"), m_id);
obj.insert(QSL("custom_id"), m_customId);
obj.insert(QSL("custom_hash"), m_customHash);
return obj;
}

View File

@ -1187,9 +1187,11 @@ QList<Message> DatabaseQueries::getFeedsSlice(const QSqlDatabase& db,
q.setForwardOnly(true);
q.prepare(QSL("SELECT %1 "
"FROM Messages "
"WHERE is_deleted = 0 AND is_pdeleted = 0 AND "
" is_read = :is_read "
" feed = :feed AND account_id = :account_id "
"WHERE is_deleted = 0 AND "
" is_pdeleted = 0 AND "
" is_read = :is_read AND "
" feed = :feed AND "
" account_id = :account_id "
"ORDER BY Messages.date_created %2 "
"LIMIT :row_limit OFFSET :row_offset;")
.arg(messageTableAttributes(true, db.driverName() == QSL(APP_DB_SQLITE_DRIVER)).values().join(QSL(", ")),
@ -1217,7 +1219,7 @@ QList<Message> DatabaseQueries::getFeedsSlice(const QSqlDatabase& db,
}
}
else {
throw ApplicationException(q.lastError().driverText());
throw ApplicationException(q.lastError().driverText() + QSL(" ") + q.lastError().databaseText());
}
return messages;

View File

@ -85,10 +85,7 @@ ApiResponse ApiServer::processArticlesFromFeed(const QJsonValue& req) const {
QJsonArray msgs_json_array;
for (const Message& msg : msgs) {
QJsonObject msg_obj;
msg_obj.insert(QSL("contents"), msg.toJson());
msgs_json_array.append(msg_obj);
msgs_json_array.append(msg.toJson());
}
ApiResponse resp(ApiResponse::Result::Success, ApiRequest::Method::ArticlesFromFeed, msgs_json_array);