From 1f6c13fdd1f9468553a93cd3f2e14c23ab6ac72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 12 Jan 2019 16:29:17 +0000 Subject: [PATCH] xep_0384: only clean specified session for a user; use existing storeSession method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks Syndace Signed-off-by: Maxime “pep” Buquet --- storage.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/storage.py b/storage.py index 60fa48e..6496d29 100644 --- a/storage.py +++ b/storage.py @@ -78,7 +78,7 @@ class SyncFileStorage(omemo.Storage): return self.__sessions.get(bare_jid, {}).get(device_id, None) - def storeSession(self, callback, bare_jid: str, device_id: int, session) -> None: + def storeSession(self, _callback, bare_jid: str, device_id: int, session) -> None: self.__sessions[bare_jid] = self.__sessions.get(bare_jid, {}) self.__sessions[bare_jid][device_id] = session @@ -86,11 +86,8 @@ class SyncFileStorage(omemo.Storage): with open(filepath, 'w') as f: json.dump(self.__sessions, f) - def deleteSession(self, callback, bare_jid: str, device_id: int) -> None: - self.__sessions[bare_jid] = {} - - filepath = os.path.join(self.storage_dir, 'sessions.json') - os.remove(filepath) + def deleteSession(self, _callback, bare_jid: str, device_id: int) -> None: + return self.storeSession(None, bare_jid, device_id, {}) def loadActiveDevices(self, _callback, bare_jid: str) -> Optional[List[int]]: if not self.__devices: