Skip to content
Snippets Groups Projects
Commit dd2d0f32 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist
Browse files

StartChat: Remove history when forgetting group chat

parent 767cd908
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@
from gajim.gui.about import AboutDialog
from gajim.gui.discovery import ServiceDiscoveryWindow
from gajim.gui.util import open_window
from gajim.gui.util import get_app_window
# General Actions
......@@ -266,10 +267,16 @@ def start_chat(_action, param):
def forget_groupchat(_action, param):
account, jid = param.unpack()
room_jid = JID.from_string(jid)
window = get_app_window('StartChatDialog')
window.remove_row(account, str(room_jid))
client = app.get_client(account)
client.get_module('Bookmarks').remove(JID.from_string(jid))
window = open_window('StartChatDialog')
window.remove_row(account, jid)
client.get_module('MUC').leave(room_jid)
client.get_module('Bookmarks').remove(room_jid)
app.storage.archive.remove_chat_history(
account, str(room_jid), groupchat=True)
def on_groupchat_join(_action, param):
account, jid = param.get_strv()
......
......@@ -1192,6 +1192,27 @@ def reset_archive_infos(self, jid):
log.info('Reset message archive info: %s', jid)
self._delayed_commit()
def remove_chat_history(self, account: str, jid: str,
groupchat: bool = False) -> None:
"""
Remove chat history for a specific chat.
If it's a group chat, remove last MAM ID as well.
"""
account_id = self.get_account_id(account)
jid_id = self.get_jid_id(jid)
sql = 'DELETE FROM logs WHERE account_id = ? AND jid_id = ?'
self._con.execute(sql, (account_id, jid_id))
sql = 'DELETE FROM jids WHERE jid_id = ?'
self._con.execute(sql, (jid_id,))
if groupchat:
sql = 'DELETE FROM last_archive_message WHERE jid_id = ?'
self._con.execute(sql, (jid_id,))
self._delayed_commit()
log.info('Removed chat history for: %s', jid)
def _cleanup_chat_history(self):
"""
Remove messages from account where messages are older than max_age
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment