buffer: Support encrypted attachments.
Note, the printed url should be passed to a helper program that will download the file and decrypt it.
This commit is contained in:
parent
45d83cc1b1
commit
60282b4eec
1 changed files with 26 additions and 0 deletions
|
@ -33,6 +33,7 @@ from nio import (
|
|||
RoomMessage,
|
||||
RoomMessageEmote,
|
||||
RoomMessageMedia,
|
||||
RoomEncryptedMedia,
|
||||
RoomMessageNotice,
|
||||
RoomMessageText,
|
||||
RoomMessageUnknown,
|
||||
|
@ -1151,6 +1152,31 @@ class RoomBuffer(object):
|
|||
nick, data, date, self.get_event_tags(event), extra_prefix
|
||||
)
|
||||
|
||||
elif isinstance(event, RoomEncryptedMedia):
|
||||
nick = self.find_nick(event.sender)
|
||||
date = server_ts_to_weechat(event.server_timestamp)
|
||||
http_url = Api.encrypted_mxc_to_plumb(
|
||||
event.url,
|
||||
event.key["k"],
|
||||
event.hashes["sha256"],
|
||||
event.iv
|
||||
)
|
||||
url = http_url if http_url else event.url
|
||||
|
||||
description = "{}".format(event.body) if event.body else "file"
|
||||
data = ("{del_color}<{ncolor}{desc}{del_color}>{ncolor} "
|
||||
"{del_color}[{ncolor}{url}{del_color}]{ncolor}").format(
|
||||
del_color=W.color("chat_delimiters"),
|
||||
ncolor=W.color("reset"),
|
||||
desc=description, url=url)
|
||||
|
||||
extra_prefix = (self.warning_prefix if event.decrypted
|
||||
and not event.verified else "")
|
||||
|
||||
self.weechat_buffer.message(
|
||||
nick, data, date, self.get_event_tags(event), extra_prefix
|
||||
)
|
||||
|
||||
elif isinstance(event, RoomMessageUnknown):
|
||||
nick = self.find_nick(event.sender)
|
||||
date = server_ts_to_weechat(event.server_timestamp)
|
||||
|
|
Loading…
Reference in a new issue