From 433d5e6f76da52ed7f7f798cfb031f164a76fb23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 21 Mar 2022 01:11:43 +0100 Subject: plugin_e2ee: new format_fingerprint method to be overriden by plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- poezio/plugin_e2ee.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py index 38ecbb83..a11337e9 100644 --- a/poezio/plugin_e2ee.py +++ b/poezio/plugin_e2ee.py @@ -34,7 +34,7 @@ from poezio.tabs import ( StaticConversationTab, ) from poezio.plugin import BasePlugin -from poezio.theming import get_theme, dump_tuple +from poezio.theming import Theme, get_theme, dump_tuple from poezio.config import config from poezio.decorators import command_args_parser @@ -273,17 +273,24 @@ class E2EEPlugin(BasePlugin): 'Info', ) + @staticmethod + def format_fingerprint(fingerprint: str, theme: Theme) -> str: + return fingerprint + async def _show_fingerprints(self, jid: JID) -> None: """Display encryption fingerprints for a JID.""" + theme = get_theme() fprs = await self.get_fingerprints(jid) if len(fprs) == 1: + fingerprint = self.format_fingerprint(fprs[0], theme) self.api.information( - f'Fingerprint for {jid}: {fprs[0]}', + f'Fingerprint for {jid}: {fingerprint}', 'Info', ) elif fprs: + fmt_fprs = map(lambda fp: self.format_fingerprint(fp, theme), fprs) self.api.information( - 'Fingerprints for %s:\n\t%s' % (jid, '\n\t'.join(fprs)), + 'Fingerprints for %s:\n\t%s' % (jid, '\n\t'.join(fmt_fprs)), 'Info', ) else: -- cgit v1.2.3