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

Fetch history only from asked profile ID

This commit is contained in:
apprb 2014-10-14 22:52:23 +09:00
parent ec3d8146c6
commit c07a0cd7f8
No known key found for this signature in database
GPG Key ID: B001911B5B22FB9B

View File

@ -116,20 +116,20 @@ QList<HistoryKeeper::HistMessage> HistoryKeeper::getChatHistory(HistoryKeeper::C
const QString &chat, const QDateTime &time_from, const QString &chat, const QDateTime &time_from,
const QDateTime &time_to) const QDateTime &time_to)
{ {
Q_UNUSED(profile)
QList<HistMessage> res; QList<HistMessage> res;
qint64 time64_from = time_from.toMSecsSinceEpoch(); qint64 time64_from = time_from.toMSecsSinceEpoch();
qint64 time64_to = time_to.toMSecsSinceEpoch(); qint64 time64_to = time_to.toMSecsSinceEpoch();
int chat_id = getChatID(chat, ct).first; int chat_id = getChatID(chat, ct).first;
int profile_id = getAliasID(profile);
QSqlQuery dbAnswer; QSqlQuery dbAnswer;
if (ct == ctSingle) if (ct == ctSingle)
{ {
dbAnswer = db.exec(QString("SELECT timestamp, user_id, message, mtype FROM history INNER JOIN aliases ON history.sender = aliases.id ") + dbAnswer = db.exec(QString("SELECT timestamp, user_id, message, mtype FROM history INNER JOIN aliases ON history.sender = aliases.id ") +
QString("AND timestamp BETWEEN %1 AND %2 AND chat_id = %3;").arg(time64_from).arg(time64_to).arg(chat_id)); QString("AND timestamp BETWEEN %1 AND %2 AND chat_id = %3 AND profile_id = %4;")
.arg(time64_from).arg(time64_to).arg(chat_id).arg(profile_id));
} else { } else {
// no groupchats yet // no groupchats yet
} }