mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix: check time for get num messages for friend (fix #5714)
This commit is contained in:
parent
033f28e67e
commit
b0f32379d0
|
@ -523,10 +523,7 @@ void History::setFileFinished(const QString& fileId, bool success, const QString
|
||||||
|
|
||||||
size_t History::getNumMessagesForFriend(const ToxPk& friendPk)
|
size_t History::getNumMessagesForFriend(const ToxPk& friendPk)
|
||||||
{
|
{
|
||||||
return getNumMessagesForFriendBeforeDate(friendPk,
|
return getNumMessagesForFriendBeforeDate(friendPk, QDateTime());
|
||||||
// Maximum possible time
|
|
||||||
QDateTime::fromMSecsSinceEpoch(
|
|
||||||
std::numeric_limits<int64_t>::max()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t History::getNumMessagesForFriendBeforeDate(const ToxPk& friendPk, const QDateTime& date)
|
size_t History::getNumMessagesForFriendBeforeDate(const ToxPk& friendPk, const QDateTime& date)
|
||||||
|
@ -534,10 +531,14 @@ size_t History::getNumMessagesForFriendBeforeDate(const ToxPk& friendPk, const Q
|
||||||
QString queryText = QString("SELECT COUNT(history.id) "
|
QString queryText = QString("SELECT COUNT(history.id) "
|
||||||
"FROM history "
|
"FROM history "
|
||||||
"JOIN peers chat ON chat_id = chat.id "
|
"JOIN peers chat ON chat_id = chat.id "
|
||||||
"WHERE chat.public_key='%1'"
|
"WHERE chat.public_key='%1'")
|
||||||
"AND timestamp < %2;")
|
.arg(friendPk.toString());
|
||||||
.arg(friendPk.toString())
|
|
||||||
.arg(date.toMSecsSinceEpoch());
|
if (date.isNull()) {
|
||||||
|
queryText += ";";
|
||||||
|
} else {
|
||||||
|
queryText += QString(" AND timestamp < %1;").arg(date.toMSecsSinceEpoch());
|
||||||
|
}
|
||||||
|
|
||||||
size_t numMessages = 0;
|
size_t numMessages = 0;
|
||||||
auto rowCallback = [&numMessages](const QVector<QVariant>& row) {
|
auto rowCallback = [&numMessages](const QVector<QVariant>& row) {
|
||||||
|
@ -798,4 +799,4 @@ void History::markAsSent(RowId messageId)
|
||||||
}
|
}
|
||||||
|
|
||||||
db->execLater(QString("DELETE FROM faux_offline_pending WHERE id=%1;").arg(messageId.get()));
|
db->execLater(QString("DELETE FROM faux_offline_pending WHERE id=%1;").arg(messageId.get()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user