api work
This commit is contained in:
parent
6b9041a110
commit
d34c2d5792
3 changed files with 16 additions and 8 deletions
|
@ -168,6 +168,15 @@ QJsonObject Message::toJson() const {
|
||||||
QJsonObject obj;
|
QJsonObject obj;
|
||||||
|
|
||||||
obj.insert(QSL("contents"), m_contents);
|
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;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1187,9 +1187,11 @@ QList<Message> DatabaseQueries::getFeedsSlice(const QSqlDatabase& db,
|
||||||
q.setForwardOnly(true);
|
q.setForwardOnly(true);
|
||||||
q.prepare(QSL("SELECT %1 "
|
q.prepare(QSL("SELECT %1 "
|
||||||
"FROM Messages "
|
"FROM Messages "
|
||||||
"WHERE is_deleted = 0 AND is_pdeleted = 0 AND "
|
"WHERE is_deleted = 0 AND "
|
||||||
" is_read = :is_read "
|
" is_pdeleted = 0 AND "
|
||||||
" feed = :feed AND account_id = :account_id "
|
" is_read = :is_read AND "
|
||||||
|
" feed = :feed AND "
|
||||||
|
" account_id = :account_id "
|
||||||
"ORDER BY Messages.date_created %2 "
|
"ORDER BY Messages.date_created %2 "
|
||||||
"LIMIT :row_limit OFFSET :row_offset;")
|
"LIMIT :row_limit OFFSET :row_offset;")
|
||||||
.arg(messageTableAttributes(true, db.driverName() == QSL(APP_DB_SQLITE_DRIVER)).values().join(QSL(", ")),
|
.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 {
|
else {
|
||||||
throw ApplicationException(q.lastError().driverText());
|
throw ApplicationException(q.lastError().driverText() + QSL(" ") + q.lastError().databaseText());
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
|
|
|
@ -85,10 +85,7 @@ ApiResponse ApiServer::processArticlesFromFeed(const QJsonValue& req) const {
|
||||||
QJsonArray msgs_json_array;
|
QJsonArray msgs_json_array;
|
||||||
|
|
||||||
for (const Message& msg : msgs) {
|
for (const Message& msg : msgs) {
|
||||||
QJsonObject msg_obj;
|
msgs_json_array.append(msg.toJson());
|
||||||
|
|
||||||
msg_obj.insert(QSL("contents"), msg.toJson());
|
|
||||||
msgs_json_array.append(msg_obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiResponse resp(ApiResponse::Result::Success, ApiRequest::Method::ArticlesFromFeed, msgs_json_array);
|
ApiResponse resp(ApiResponse::Result::Success, ApiRequest::Method::ArticlesFromFeed, msgs_json_array);
|
||||||
|
|
Loading…
Add table
Reference in a new issue