From cfae54576aa2521608d1ca1fffeee67f29e251eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 2 Oct 2018 13:01:32 +0200 Subject: [PATCH] completion: Fix olm user/device completion. --- matrix/completion.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/matrix/completion.py b/matrix/completion.py index bf00682..67c78b9 100644 --- a/matrix/completion.py +++ b/matrix/completion.py @@ -154,9 +154,12 @@ def matrix_olm_user_completion_cb(data, completion_item, buffer, completion): if not server: return W.WEECHAT_RC_OK - olm = server.olm + olm = server.client.olm - for user in olm.device_keys: + if not olm: + return W.WEECHAT_RC_OK + + for user in olm.device_store.users: W.hook_completion_list_add( completion, user, 0, W.WEECHAT_LIST_POS_SORT ) @@ -171,7 +174,10 @@ def matrix_olm_device_completion_cb(data, completion_item, buffer, completion): if not server: return W.WEECHAT_RC_OK - olm = server.olm + olm = server.client.olm + + if not olm: + return W.WEECHAT_RC_OK args = W.hook_completion_get_string(completion, "args") @@ -182,12 +188,12 @@ def matrix_olm_device_completion_cb(data, completion_item, buffer, completion): user = fields[1] - if user not in olm.device_keys: + if user not in olm.device_store.users: return W.WEECHAT_RC_OK - for device in olm.device_keys[user]: + for device in olm.device_store[user]: W.hook_completion_list_add( - completion, device.device_id, 0, W.WEECHAT_LIST_POS_SORT + completion, device, 0, W.WEECHAT_LIST_POS_SORT ) return W.WEECHAT_RC_OK