commands: Misc olm command fixes.

This commit is contained in:
Damir Jelić 2018-10-14 12:47:47 +02:00
parent d66621578b
commit 868a47eca7

View file

@ -380,7 +380,7 @@ def olm_info_command(server, args):
def print_devices( def print_devices(
device_store, device_store,
filter_regex, filter_regex,
device_category="Device", device_category="All",
predicate=None, predicate=None,
): ):
user_strings = [] user_strings = []
@ -424,23 +424,18 @@ def olm_info_command(server, args):
W.prnt(server.server_buffer, message) W.prnt(server.server_buffer, message)
return return
W.prnt(server.server_buffer, server.info("{} devices:\n".format(device_category))
"{}matrix: {} devices:\n".format(
W.prefix("network"),
device_category
))
W.prnt(server.server_buffer, "\n".join(user_strings)) W.prnt(server.server_buffer, "\n".join(user_strings))
olm = server.client.olm olm = server.client.olm
if args.category == "private": if args.category == "private":
fp_key = partition_key(olm.account.identity_keys["ed25519"]) fp_key = partition_key(olm.account.identity_keys["ed25519"])
message = ("{prefix}matrix: Identity keys:\n" message = ("Identity keys:\n"
" - User: {user_color}{user}{ncolor}\n" " - User: {user_color}{user}{ncolor}\n"
" - Device ID: {device_color}{device_id}{ncolor}\n" " - Device ID: {device_color}{device_id}{ncolor}\n"
" - Device key: {key_color}{fp_key}{ncolor}\n" " - Device key: {key_color}{fp_key}{ncolor}\n"
"").format( "").format(
prefix=W.prefix("network"),
user_color=W.color("chat_self"), user_color=W.color("chat_self"),
ncolor=W.color("reset"), ncolor=W.color("reset"),
user=olm.user_id, user=olm.user_id,
@ -448,7 +443,7 @@ def olm_info_command(server, args):
device_id=olm.device_id, device_id=olm.device_id,
key_color=W.color("chat_server"), key_color=W.color("chat_server"),
fp_key=fp_key) fp_key=fp_key)
W.prnt(server.server_buffer, message) server.info(message)
elif args.category == "all": elif args.category == "all":
print_devices(olm.device_store, args.filter) print_devices(olm.device_store, args.filter)