From f755df9dba833b1371ed0c0e152a36e814926943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 22 Jan 2020 17:42:36 +0100 Subject: [PATCH] Ensure data path works on most FS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also following the same changes in python-omemo. Signed-off-by: Maxime “pep” Buquet --- poezio_plugins/omemo/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/poezio_plugins/omemo/__init__.py b/poezio_plugins/omemo/__init__.py index 49054f1..0e0fe3c 100644 --- a/poezio_plugins/omemo/__init__.py +++ b/poezio_plugins/omemo/__init__.py @@ -12,6 +12,8 @@ import os import asyncio +import base64 +import hashlib import logging from typing import Dict, List, Optional @@ -60,7 +62,10 @@ class Plugin(E2EEPlugin): self.info = lambda i: self.api.information(i, 'Info') - data_dir = os.path.join(DATA_HOME, 'omemo', self.core.xmpp.boundjid.bare) + jid_str = self.core.xmpp.boundjid.bare.encode('US-ASCII') + digest = hashlib.sha256(jid_str).digest() + hashed_jid = base64.b32encode(digest).decode('US-ASCII') + data_dir = os.path.join(DATA_HOME, 'omemo', hashed_jid) os.makedirs(data_dir, exist_ok=True) try: