mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Removes chat history of friend when removed, fixes #1486
This commit is contained in:
parent
885dc0638a
commit
07ba0c9ae0
|
@ -138,6 +138,24 @@ HistoryKeeper::~HistoryKeeper()
|
|||
delete db;
|
||||
}
|
||||
|
||||
void HistoryKeeper::removeFriendHistory(const QString& chat)
|
||||
{
|
||||
int chat_id = getChatID(chat, ctSingle).first;
|
||||
|
||||
db->exec("BEGIN TRANSACTION;");
|
||||
|
||||
QString cmd = QString("DELETE FROM chats WHERE name = '%1';").arg(chat);
|
||||
db->exec(cmd);
|
||||
cmd = QString("DELETE FROM aliases WHERE user_id = '%1';").arg(chat);
|
||||
db->exec(cmd);
|
||||
cmd = QString("DELETE FROM sent_status WHERE id IN (SELECT id FROM history WHERE chat_id = '%1');").arg(chat_id);
|
||||
db->exec(cmd);
|
||||
cmd = QString("DELETE FROM history WHERE chat_id = '%1';").arg(chat_id);
|
||||
db->exec(cmd);
|
||||
|
||||
db->exec("COMMIT TRANSACTION;");
|
||||
}
|
||||
|
||||
qint64 HistoryKeeper::addChatEntry(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt, bool isSent)
|
||||
{
|
||||
QList<QString> cmds = generateAddChatEntryCmd(chat, message, sender, dt, isSent);
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
static bool removeHistory(int encrypted = -1);
|
||||
static QList<HistMessage> exportMessagesDeleteFile(int encrypted = -1);
|
||||
|
||||
void removeFriendHistory(const QString& chat);
|
||||
qint64 addChatEntry(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt, bool isSent);
|
||||
qint64 addGroupChatEntry(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt);
|
||||
QList<HistMessage> getChatHistory(ChatType ct, const QString &chat, const QDateTime &time_from, const QDateTime &time_to);
|
||||
|
|
|
@ -825,6 +825,7 @@ void Widget::removeFriend(Friend* f, bool fake)
|
|||
}
|
||||
FriendList::removeFriend(f->getFriendID(), fake);
|
||||
Nexus::getCore()->removeFriend(f->getFriendID(), fake);
|
||||
HistoryKeeper::getInstance()->removeFriendHistory(f->getToxID().publicKey);
|
||||
delete f;
|
||||
if (ui->mainHead->layout()->isEmpty())
|
||||
onAddClicked();
|
||||
|
|
Loading…
Reference in New Issue
Block a user