1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #5715

TriKriSta (1):
      fix: check time for get num messages for friend (fix #5714)
This commit is contained in:
sudden6 2019-06-26 08:57:17 +02:00
commit a5754ab0bb
No known key found for this signature in database
GPG Key ID: 279509B499E032B9

View File

@ -523,10 +523,7 @@ void History::setFileFinished(const QString& fileId, bool success, const QString
size_t History::getNumMessagesForFriend(const ToxPk& friendPk)
{
return getNumMessagesForFriendBeforeDate(friendPk,
// Maximum possible time
QDateTime::fromMSecsSinceEpoch(
std::numeric_limits<int64_t>::max()));
return getNumMessagesForFriendBeforeDate(friendPk, QDateTime());
}
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) "
"FROM history "
"JOIN peers chat ON chat_id = chat.id "
"WHERE chat.public_key='%1'"
"AND timestamp < %2;")
.arg(friendPk.toString())
.arg(date.toMSecsSinceEpoch());
"WHERE chat.public_key='%1'")
.arg(friendPk.toString());
if (date.isNull()) {
queryText += ";";
} else {
queryText += QString(" AND timestamp < %1;").arg(date.toMSecsSinceEpoch());
}
size_t numMessages = 0;
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()));
}
}